I see that it's possible to launch the date & time settings via an intent in Android, but what I'd like to do is launch just the list that shows the time zones (clicking "Select time zone") and get back the selected value without having the selection modify the user's date & time settings. Any idea how to do this?
If you are talking about a spinner you could do something like this:
ArrayAdapter <CharSequence> adapter =
new ArrayAdapter <CharSequence> (this, android.R.layout.simple_spinner_item );
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
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());
}
}
for(int i = 0; i < TZ1.size(); i++) {
adapter.add(TZ1.get(i));
}
final Spinner TZone = (Spinner)findViewById(R.id.TimeZoneEntry);
TZone.setAdapter(adapter);
for(int i = 0; i < TZ1.size(); i++) {
if(TZ1.get(i).equals(TimeZone.getDefault().getDisplayName())) {
TZone.setSelection(i);
}
}
Take a look here for more literature on TimeZone
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With