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.

Locale location Java Android example


Locale lc = Locale.getDefault(); // default now locale on device
	String sCountry = lc.getCountry(); // CZ
	
	lc = new Locale("fr","FR"); //FRANCE .. Locale(language, country);
	String sCountry2 = lc.getDisplayCountry(); // Francie

	 Locale locale = Locale.GERMAN;					    
	 String sCountry3 = locale.getDisplayCountry(); // ""

 Locale locale = Locale.GERMAN;
 DateFormat formatter = new SimpleDateFormat("HH:mm:ss zzzz", locale);
 String s = formatter.format(new Date());//13:40:39 GMT+00:00					


// array of locales   
 Locale[] locales = { new Locale("fr", "FR"), new Locale("de", "DE"),
				        new Locale("en", "US") };


Locale locale = Locale.US;

// for date
DateFormat dateFormatterEurope = DateFormat.getDateInstance(DateFormat.DEFAULT,
					Locale.GERMANY);
Calendar myCalendar = Calendar.getInstance();
String sDate = dateFormatterEurope.format(myCalendar.getTime());

        final byte[] langBytes = locale.getLanguage().getBytes(Charsets.US_ASCII);
        
// UTF-8 most widely used text format for to properly display of text
        final Charset utfEncoding = Charsets.UTF_8;
        String text = "ěščřžýáíéůú"; 
        final byte[] textBytes = text.getBytes(utfEncoding);


// other Locale
CANADA
CANADA_FRENCH
CHINA
CHINESE
ENGLISH
FRANCE
FRENCH
GERMAN
GERMANY
ITALIAN
ITALY
JAPAN
JAPANESE
KOREA
KOREAN
PRC // Locale constant for zh_CN. 
ROOT // Locale constant for the root locale. 
SIMPLIFIED_CHINESE
TAIWAN
TRADITIONAL_CHINESE Locale constant for zh_TW. 
UK
US

396LW NO topic_id




AD

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


132

Draw circle Android basic example | draw-circle-android-basic-example


Canvas, drawCircle(), Paint, onDraw(), setStrokeWidth(), setStyle()

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) {

			canvas.drawColor(Color.CYAN);
			Paint p = new Paint();
			// smooths
			p.setAntiAlias(true);
			p.setColor(Color.RED);
			p.setStyle(Paint.Style.STROKE); 
			p.setStrokeWidth(4.5f);
			// opacity
			//p.setAlpha(0x80); //
			canvas.drawCircle(50, 50, 30, p);
		}

	}
}

215

Java pass variable as reference | java-pass-variable-as-reference


Integer, Float, String, List passed as reference in JAVA example source code:

// List passed as reference JAVA
List<Integer>list = new ArrayList<Integer>();

public void fc (List<Integer>listRef){
listRef.add(7);
listRef.add(5);
}
fc(list); // 7, 5 


// String passed as reference JAVA
	public void mutate(AtomicReference<Object> ref) { ref.set("Goodbye"); }

		AtomicReference<Object> ref = new AtomicReference<Object>("Hello");
		mutate(ref);
		System.out.println(ref.get()); //Goodbye!
             String s = (String) ref.get();


// Integer passed as reference JAVA
	private static void mutate(AtomicReference<Object> ref) { ref.set(7); }

	//public static void main(String[] arg) {
		AtomicReference<Object> ref = new AtomicReference<Object>(5);
		mutate(ref);
		System.out.println(ref.get()); // 7
int n = (Integer) ref.get();


// Float passed as reference JAVA
	private static void mutate(AtomicReference<Object> ref) { ref.set(14.8f); }

	//public static void main(String[] arg) {
		AtomicReference<Object> ref = new AtomicReference<Object>(12.1f);
		mutate(ref);
		float f = (Float) ref.get();
		System.out.println(f); //14.8

35

Android startup tutorial for developers video | android-startup-tutorial-for-developers-video


How install Android emulator on PC
//developer.android.com/sdk/installing.html

Download links:
Java Development Kit JDK download
Eclipse download
Android SDK download