am 532fc970: am 34a5e96b: am 070228fa: Merge "Extend the TimePickerDialog test to cover 12- and 24-hour clocks."
* commit '532fc97091883b5f04fd746f5bfbb8f9ad12fa15': Extend the TimePickerDialog test to cover 12- and 24-hour clocks.
This commit is contained in:
@@ -32,9 +32,14 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/date_widgets_example_pickDate_text"/>
|
android:text="@string/date_widgets_example_pickDate_text"/>
|
||||||
|
|
||||||
<Button android:id="@+id/pickTime"
|
<Button android:id="@+id/pickTime12"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/date_widgets_example_pickTime_text"/>
|
android:text="@string/date_widgets_example_pickTime12_text"/>
|
||||||
|
|
||||||
|
<Button android:id="@+id/pickTime24"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/date_widgets_example_pickTime24_text"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -1348,7 +1348,8 @@
|
|||||||
<string name="text_switcher_1_next_text">Next</string>
|
<string name="text_switcher_1_next_text">Next</string>
|
||||||
|
|
||||||
<string name="date_widgets_example_dateDisplay_text"></string>
|
<string name="date_widgets_example_dateDisplay_text"></string>
|
||||||
<string name="date_widgets_example_pickTime_text">change the time</string>
|
<string name="date_widgets_example_pickTime12_text">change the time (12 hour)</string>
|
||||||
|
<string name="date_widgets_example_pickTime24_text">change the time (24 hour)</string>
|
||||||
<string name="date_widgets_example_pickDate_text">change the date</string>
|
<string name="date_widgets_example_pickDate_text">change the date</string>
|
||||||
|
|
||||||
<string name="buttons_1_normal">Normal</string>
|
<string name="buttons_1_normal">Normal</string>
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ public class DateWidgets1 extends Activity {
|
|||||||
private int mHour;
|
private int mHour;
|
||||||
private int mMinute;
|
private int mMinute;
|
||||||
|
|
||||||
static final int TIME_DIALOG_ID = 0;
|
static final int TIME_12_DIALOG_ID = 0;
|
||||||
static final int DATE_DIALOG_ID = 1;
|
static final int TIME_24_DIALOG_ID = 1;
|
||||||
|
static final int DATE_DIALOG_ID = 2;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -62,21 +63,9 @@ public class DateWidgets1 extends Activity {
|
|||||||
|
|
||||||
mDateDisplay = (TextView) findViewById(R.id.dateDisplay);
|
mDateDisplay = (TextView) findViewById(R.id.dateDisplay);
|
||||||
|
|
||||||
Button pickDate = (Button) findViewById(R.id.pickDate);
|
setDialogOnClickListener(R.id.pickDate, DATE_DIALOG_ID);
|
||||||
pickDate.setOnClickListener(new View.OnClickListener() {
|
setDialogOnClickListener(R.id.pickTime12, TIME_12_DIALOG_ID);
|
||||||
|
setDialogOnClickListener(R.id.pickTime24, TIME_24_DIALOG_ID);
|
||||||
public void onClick(View v) {
|
|
||||||
showDialog(DATE_DIALOG_ID);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Button pickTime = (Button) findViewById(R.id.pickTime);
|
|
||||||
pickTime.setOnClickListener(new View.OnClickListener() {
|
|
||||||
|
|
||||||
public void onClick(View v) {
|
|
||||||
showDialog(TIME_DIALOG_ID);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final Calendar c = Calendar.getInstance();
|
final Calendar c = Calendar.getInstance();
|
||||||
mYear = c.get(Calendar.YEAR);
|
mYear = c.get(Calendar.YEAR);
|
||||||
@@ -88,12 +77,22 @@ public class DateWidgets1 extends Activity {
|
|||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setDialogOnClickListener(int buttonId, final int dialogId) {
|
||||||
|
Button b = (Button) findViewById(buttonId);
|
||||||
|
b.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
showDialog(dialogId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog(int id) {
|
protected Dialog onCreateDialog(int id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case TIME_DIALOG_ID:
|
case TIME_12_DIALOG_ID:
|
||||||
|
case TIME_24_DIALOG_ID:
|
||||||
return new TimePickerDialog(this,
|
return new TimePickerDialog(this,
|
||||||
mTimeSetListener, mHour, mMinute, false);
|
mTimeSetListener, mHour, mMinute, id == TIME_24_DIALOG_ID);
|
||||||
case DATE_DIALOG_ID:
|
case DATE_DIALOG_ID:
|
||||||
return new DatePickerDialog(this,
|
return new DatePickerDialog(this,
|
||||||
mDateSetListener,
|
mDateSetListener,
|
||||||
@@ -105,7 +104,8 @@ public class DateWidgets1 extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPrepareDialog(int id, Dialog dialog) {
|
protected void onPrepareDialog(int id, Dialog dialog) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case TIME_DIALOG_ID:
|
case TIME_12_DIALOG_ID:
|
||||||
|
case TIME_24_DIALOG_ID:
|
||||||
((TimePickerDialog) dialog).updateTime(mHour, mMinute);
|
((TimePickerDialog) dialog).updateTime(mHour, mMinute);
|
||||||
break;
|
break;
|
||||||
case DATE_DIALOG_ID:
|
case DATE_DIALOG_ID:
|
||||||
|
|||||||
Reference in New Issue
Block a user