申し訳ありませんが、以前の質問で検索しましたが、答えが見つかりませんでした。日付ピッカーと時間ピッカーがありますが、実行すると時間ピッカー ダイアログが表示されません。何か案が?私は何時間も答えを探しました、これは私が持っているコードです:
public class BuildingFireActivity extends Activity {
private Button buildingfirePickDate;
private Button buildingfiredispatchPickTime;
private TextView buildingfireDateDisplay;
private TextView buildingfiredispatchTimeDisplay;
private int buildingfireYear;
private int buildingfireMonth;
private int buildingfireDay;
private int buildingfiredispatchHour;
private int buildingfiredispatchMinute;
static final int DATE_DIALOG_ID = 0;
static final int TIME_DIALOG_ID = 1;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.buildingfirelayout);
buildingfirePickDate = (Button) findViewById(R.id.pickDate);
buildingfiredispatchPickTime = (Button) findViewById(R.id.dispatchTime);
buildingfireDateDisplay = (TextView) findViewById(R.id.dateDisplay);
buildingfiredispatchTimeDisplay = (TextView) findViewById(R.id.dispatchDisplay);
buildingfirePickDate.setOnClickListener(new View.OnClickListener() {
@SuppressWarnings("deprecation")
public void onClick(View v) {
showDialog(DATE_DIALOG_ID);}});
final Calendar c = Calendar.getInstance();
buildingfireYear = c.get(Calendar.YEAR);
buildingfireMonth = c.get(Calendar.MONTH);
buildingfireDay = c.get(Calendar.DAY_OF_MONTH);
updateDisplay();
buildingfiredispatchPickTime.setOnClickListener(new View.OnClickListener() {
@SuppressWarnings("deprecation")
public void onClick(View v) {
showDialog(TIME_DIALOG_ID);}});
final Calendar dispatch = Calendar.getInstance();
buildingfiredispatchHour = dispatch.get(Calendar.HOUR_OF_DAY);
buildingfiredispatchMinute = dispatch.get(Calendar.MINUTE);
updateDisplay1();}
private static String pad(int dispatch) {
if (dispatch >= 10)
return String.valueOf(dispatch);
else
return "0" + String.valueOf(dispatch);}
private void updateDisplay() {
buildingfireDateDisplay.setText(
new StringBuilder()
.append(buildingfireMonth + 1).append("-")
.append(buildingfireDay).append("-")
.append(buildingfireYear).append(" "));}
private void updateDisplay1() {
buildingfiredispatchTimeDisplay.setText(
new StringBuilder()
.append(pad(buildingfiredispatchHour)).append(":")
.append(pad(buildingfiredispatchMinute)));}
private DatePickerDialog.OnDateSetListener buildingfireDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
buildingfireYear = year;
buildingfireMonth = monthOfYear;
buildingfireDay = dayOfMonth;
updateDisplay();}};
private TimePickerDialog.OnTimeSetListener buildingfiredispatchTimeSetListener =
new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
buildingfiredispatchHour = hourOfDay;
buildingfiredispatchMinute = minute;
updateDisplay1();}};
protected Dialog onCreateDialog(int id) {
switch (id) {
case TIME_DIALOG_ID:
return new TimePickerDialog(this,
buildingfiredispatchTimeSetListener,
buildingfiredispatchHour,
buildingfiredispatchMinute, false);}
return null;}
@Override
protected Dialog onCreateDialog1(int id) {
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this,
buildingfireDateSetListener,
buildingfireYear,
buildingfireMonth,
buildingfireDay);}
return null;}}