我正在制作一个使用 TimePicker 的应用程序,这是我第一次使用它。我的代码如下:
final Dialog mTimeDialog = new Dialog(this);
TimePicker timePicker = (TimePicker)mTimeDialog.findViewById(R.id.timePicker);
TimePicker timePicker1 = (TimePicker)mTimeDialog.findViewById(R.id.timePicker1);
int starthour = timePicker.getCurrentHour();
int startminute = timePicker.getCurrentMinute();
int finishhour = timePicker1.getCurrentHour();
int finishminute = timePicker1.getCurrentMinute();
但是当我尝试运行它时出现异常。当我按下触发onClick
包含此内容的保存按钮时,我得到以下信息:
Caused by: java.lang.NullPointerException
at com.csam.hourtracker.hourentry.onClick(hourentry.java:40)
任何帮助都会很棒!