Question Detail

how can i implement time zone in the spinner 
<Spinner
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAlignment="center"
   >

</Spinner>


Thread Reply

Anonymous

- 1 years ago

String[]TZ = TimeZone.getAvailableIDs();
        ArrayList<String> TZ1 = new ArrayList<String>();
        for(int i = 0; i < TZ.length; i++) {
            if(!(TZ1.contains(TimeZone.getTimeZone(TZ[i]).getDisplayName()))) {
                TZ1.add(TimeZone.getTimeZone(TZ[i]).getDisplayName());
            }
        } 

I think this one is help you

Anonymous

- 1 years ago

void str() {
    Locale[] locale = Locale.getAvailableLocales();
    ArrayList<String> countries = new ArrayList<String>();
    String country;
    for (Locale loc : locale) {
        country = loc.getDisplayCountry();
        if (country.length() > 0 && !countries.contains(country)) {
            countries.add(country);
        }
    }
    Collections.sort(countries, String.CASE_INSENSITIVE_ORDER);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, countries);
    citizenship.setAdapter(adapter);
}