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)
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);
}
}
}
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
How install Android emulator on PC
//developer.android.com/sdk/installing.html
Download links:
Java Development Kit JDK download
Eclipse download
Android SDK download
//developer.android.com/sdk/installing.html
Download links:
Java Development Kit JDK download
Eclipse download
Android SDK download
Google Android button example source code for developers.
// get handle
Button myButton;
myButton = (Button)findViewById(R.id.idMyButton);
//set focus
myButton.requestFocus();
// set background image
myButton.setBackgroundResource(R.drawable.backImage);
// or
myButton.setBackgroundDrawable(getResources().getDrawable( R.drawable.someImage));
// set visibility
myButton.setVisibility(View.INVISIBLE); // VISIBLE
///////// SET LISTENER
Button myButton =(Button)findViewById(R.id.button1);
myButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "AHOJ",
Toast.LENGTH_LONG).show();
}
});
// or set onClickListener
myButton.setOnClickListener(myListener);
//end onCreate .....
private OnClickListener myListener = new OnClickListener() {
public void onClick(View v) {
}
}
Špičkový smartphone od Samsungu.
Technické parametry Samsung i9300 Galaxy S III
Rozměry a hmotnost: 137 x 71 x 9 mm, 133 gramů
Datové funkce: GPS modul, WiFi, Bluetooth, NFC, GPRS, EDGE, HSCSD, Hardwarový modem, Infraport
Sítě: pásma GSM 850, 900, 1 800, 1 900 MHz pásma WCDMA (3G) 850, 900, 1 900, 2 100 MHz
Displej: HD Super AMOLED diplej o velikosti 1280x720 4,8 palců
Procesor: čtyřjádrový procesor 1.4 GHz
Uživatelská paměť: 16 MB
paměť RAM 1 024 MB
Operační systém: Android 4.0 ICS
Hudba: MP3
Video: HD rozlišení
Fotoaparát: 8 Mpix
Navigace:
Baterie: Li-Pol, pohotovostní doba 390 hodin
Cena: cca 14.500 korun / léto 2012
Samsung i9300 Galaxy S III obrázek
Technické parametry Samsung i9300 Galaxy S III
Rozměry a hmotnost: 137 x 71 x 9 mm, 133 gramů
Datové funkce: GPS modul, WiFi, Bluetooth, NFC, GPRS, EDGE, HSCSD, Hardwarový modem, Infraport
Sítě: pásma GSM 850, 900, 1 800, 1 900 MHz pásma WCDMA (3G) 850, 900, 1 900, 2 100 MHz
Displej: HD Super AMOLED diplej o velikosti 1280x720 4,8 palců
Procesor: čtyřjádrový procesor 1.4 GHz
Uživatelská paměť: 16 MB
paměť RAM 1 024 MB
Operační systém: Android 4.0 ICS
Hudba: MP3
Video: HD rozlišení
Fotoaparát: 8 Mpix
Navigace:
Baterie: Li-Pol, pohotovostní doba 390 hodin
Cena: cca 14.500 korun / léto 2012
Samsung i9300 Galaxy S III obrázek
Editace: 2011-10-06 13:02:01
Počet článků v kategorii: 396
Url:locale-location-java-android-example