Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Replace graphic accent diacritic Java Function



Replace diacritic marks: Á Č Ď É Ě Í Ň Ó Ř Š Ť Ú Ů Ý Ž
á č ď é ě í ň ó ř š ť ú ů ý ž


public String replaceDiacritic (String inputStr) {
	
	Map<String, String> replacements = new LinkedHashMap<String,String>() {{
		//Velká
		put("Á","A");
		put("Č","C");
		put("Ď","D");
		put("É","E");
		put("Ě","E");
		put("Í","I");
		put("Ň","N");
		put("Ó","O");
		put("Ř","R");
		put("Š","S");
		put("Ť","T");
		put("Ú","U");
		put("Ů","U");
		put("Ý","Y");
		put("Ž","Z");
		//Malá  "," ");
		put("á","a");
		put("č","c");
		put("ď","d");
		put("é","e");
		put("ě","e");
		put("í","i");
		put("ň","n");
		put("ó","o");
		put("ř","r");
		put("š","s");
		put("ť","t");
		put("ú","u");
		put("ů","u");
		put("ý","y");
		put("ž","z");
		}
	};
	for(Map.Entry<String, String> entry : replacements.entrySet()) {
          inputStr =  inputStr.replaceAll(entry.getKey(), entry.getValue());
         }	
	return inputStr;
}
	

397LW NO topic_id



Další témata ....(Topics)


219

Throwing multiple exceptions Java | throwing-multiple-exceptions-java


Throws multiple exceptions Java example source code

	public void callFc() 
	throws IndexOutOfBoundsException, ArithmeticException
	{
         // my code for example:
         String[] sArray = {"aa","bb"};
         String str = sArray[5]; // IndexOutOfBoundsException

         int n = 5 / 0; // ArithmeticException
        }

public void someFC (){
try{
     callFc();
    }
 catch(IndexOutOfBoundsException e){
      Log.e("TAG", e.toString());
  }
 catch(ArithmeticException e2){ 
      Log.e2("TAG",e2.toString()); 
  }
}

345

android.app.Application cannot be cast to android.app.Activity | android-app-application-cannot-be-cast-to-android-app-activity


If you using Context as parameter of function try this solution:

public class MyActivity extends Activity {
// bla bla bla .......
//error 
myFc( getapplicationcontext());
// OK
myFc(MyActivity.this);
231

Which version of eclipse for android development | which-version-of-eclipse-for-android-development


I tried this Eclipse and work fine:
Eclipse Classic
//www.filehippo.com/download_eclipse_classic_32/

Eclipse Juno
Eclipse Helios

//developer.android.com/tools/sdk/eclipse-adt.html
141

Create monochromatic bitmap Android example | create-monochromatic-bitmap-android-example



public class MainActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}
		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();
			
			canvas.drawColor(Color.GREEN);
            
            Bitmap b = Bitmap.createBitmap(200, 200, Bitmap.Config.ALPHA_8);
             paint.setColor(Color.BLUE);
            
           Canvas c = new Canvas(b);
           c.drawRect(0, 0, 200, 200, paint);
           
           canvas.drawBitmap(b, 10,10, paint);
		}

	}
}



monochromatic bitmap
267

Whittled superscript sup tag TextView Android issue | whittled-superscript-sup-tag-textview-android-issue


Issue: Cropped superscript index between tags sup /sup is not correctly visible in TextView or View as Button.

String s = "10<sup>12 </sup>";
textView.setText(Html.fromHtml(s)); // 12 will cropped 
// solution:
s = "10<sup>12 </sup>\t	"; // add behind ending of sup tag the tabulator \t, 
// but not char \t but only press to TAB key!!! in source code
textView.setText(Html.fromHtml(s)); // 12 is visible correctly


textview-superscript-issue


Editace Jana Žákovská : 2013-01-02 12:12:34
Počet článků v kategorii: 397
Url:replace-graphic-accent-java-function
Share
Share
Tweet