Get details of Locale

Get details of Locale - Hello Friend GENERAL INFO FOR ANDROID DEVELOPMENT, In the article you read this time with the title Get details of Locale, 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 details of Locale
link : Get details of Locale

Read also

Get details of Locale

Last exercise list available Locale of the system. It's modified to display details of the clicked Locale.

Get details of Locale

package com.example.androidlocale;

import java.util.Locale;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

protected void onCreate(Bundle savedInstanceState) {

TextView textViewDefaultLocale = (TextView)findViewById(;
TextView textViewNoOfLocale = (TextView)findViewById(;
ListView listViewAvailableLocale = (ListView)findViewById(;

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

final 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);

new OnItemClickListener(){

public void onItemClick(AdapterView<?> parent,
View view, int position, long id) {
Locale item = availableLocales[position];

"Language: " + item.getLanguage() + "\n"
+ "Country: " + item.getCountry() + "\n"
+ "DisplayName: " + item.getDisplayName() + "\n"
+ "DisplayLanguage: " + item.getDisplayLanguage() + "\n"
+ "DisplayCountry: " + item.getDisplayCountry(),



Keep using the layout in last exercise.

Next: Create SimpleDateFormat for specified Locale

Thus Article Get details of Locale

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

You are now reading the article Get details of Locale with the link address

0 Response to "Get details of Locale"

Post a Comment