Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add More Time Zones
  • Loading branch information
dragosholban committed Mar 10, 2018
1 parent 85da4af commit 40e18d3
Showing 1 changed file with 15 additions and 0 deletions.
Expand Up @@ -5,7 +5,10 @@
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SeekBar;
import android.widget.TextView;

Expand All @@ -18,6 +21,8 @@ public class MainActivity extends AppCompatActivity {
Button dateBtn;
Button selectTimeZoneBtn;
TimeZone userTimeZone;
String[] selectedTimezones = new String[] {"Europe/Bucharest", "Europe/London", "Europe/Paris"};
TimeZone selectedTimeZone;

private static int CHOOSE_TIME_ZONE_REQUEST_CODE = 1;

Expand Down Expand Up @@ -55,6 +60,16 @@ public void onStopTrackingTouch(SeekBar seekBar) {
dateBtn.setText(DateFormat.getDateInstance().format(localDate));

selectTimeZoneBtn = findViewById(R.id.timeZoneButton);

ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_activated_1, android.R.id.text1, selectedTimezones);
ListView listView = findViewById(R.id.listView);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
selectedTimeZone = TimeZone.getTimeZone(selectedTimezones[i]);
}
});
}

public void showDatePicker(View view) {
Expand Down

0 comments on commit 40e18d3

Please sign in to comment.