0
我從timepickerdialog有2個字符串格式的時間。我想不通如何比較我的第一個字符串時間到當前時間。在time1-time2期間,我想顯示一個簡單的通知。我讀過很多沒有運氣的文檔。也許一個詳細的教程或源代碼會有幫助。比較字符串時間與當前時間android
在此先感謝
這裏是我的代碼:
final Button time1 = (Button) findViewById(R.id.button1);
time1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar now = Calendar.getInstance();
TimePickerDialog dpd = TimePickerDialog.newInstance(
Scheduler.this,
now.get(Calendar.HOUR_OF_DAY),
now.get(Calendar.MINUTE), true
);
dpd.show(getFragmentManager(), "Timepickerdialog");
dpd.setOnTimeSetListener(new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(RadialPickerLayout radialPickerLayout, int selectedhour, int selectedminute) {
time1.setText(pad(selectedhour) + " : " + pad(selectedminute));
}
});
}
});
final Button time2 = (Button) findViewById(R.id.button2);
time2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar now = Calendar.getInstance();
TimePickerDialog dpd = TimePickerDialog.newInstance(
Scheduler.this,
now.get(Calendar.HOUR_OF_DAY),
now.get(Calendar.MINUTE), true
);
dpd.show(getFragmentManager(), "Timepickerdialog");
dpd.setOnTimeSetListener(new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(RadialPickerLayout radialPickerLayout, int selectedhour, int selectedminute) {
time2.setText(pad(selectedhour) + " : " + pad(selectedminute));
}
});
}
});
謝謝!!你做對了,這真的很有幫助。 – tothkris