Get default Locale and available Locales

Get default Locale and available Locales - Hello Friend GENERAL INFO FOR ANDROID DEVELOPMENT, In the article you read this time with the title Get default Locale and available Locales, We have prepared this article for you to read and retrieve information there in. Hopefully the contents of postings Artikel Android code sample: Locale, We write this you can understand. Alright, good read.

The Title : Get default Locale and available Locales
link : Get default Locale and available Locales

Read also


Get default Locale and available Locales

Example to get default Locale and available Locales:

Get default Locale and available Locales


package com.example.androidlocale;

import java.util.Locale;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.app.Activity;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

TextView textViewDefaultLocale = (TextView)findViewById(R.id.defaultlocale);
TextView textViewNoOfLocale = (TextView)findViewById(R.id.numberoflocale);
ListView listViewAvailableLocale = (ListView)findViewById(R.id.listviewlocale);

Locale defaultLocale = Locale.getDefault();
textViewDefaultLocale.setText("Default Locale: " + defaultLocale.toString());

Locale[] availableLocales = Locale.getAvailableLocales();
textViewNoOfLocale.setText("Number of available Locale: " + availableLocales.length);
String[] availableLocalesString = new String[availableLocales.length];

for (int i=0; i<availableLocales.length; i++){
availableLocalesString[i] = availableLocales[i].toString();
}

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, availableLocalesString);
listViewAvailableLocale.setAdapter(adapter);

}

}


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold" />
<TextView
android:id="@+id/defaultlocale"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/numberoflocale"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ListView
android:id="@+id/listviewlocale"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

</LinearLayout>

next: Get details of Locale



Thus Article Get default Locale and available Locales

The End Article Get default Locale and available Locales This time, hopefully can give benefits to all of you. well, see you in posting other articles.

You are now reading the article Get default Locale and available Locales with the link address http://xorislogo.blogspot.com/2013/09/get-default-locale-and-available-locales.html

0 Response to "Get default Locale and available Locales"

Post a Comment