package nav.library.new23db;
public class aaaa extends AppCompatActivity {
Button button_stpd;
static final int DIALOG_ID = 0;
int minute_x;
int hour_x;
@Override
protected void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
setContentView(R.layout.aaaa);
showTimePickerDialog();
}
public void showTimePickerDialog() {
button_stpd = (Button) findViewById(R.id.button);
button_stpd.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
showDialog(DIALOG_ID);
}
}
);
}
@Override
protected Dialog onCreateDialog(int id) {
if (id == DIALOG_ID)
return new TimePickerDialog(aaaa.this, kTimePickerListner, hour_x, minute_x, false);
return null;
}
protected TimePickerDialog.OnTimeSetListener kTimePickerListner =
new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
hour_x = hourOfDay;
minute_x = minute;
Toast.makeText(aaaa.this, hour_x + " : " + minute_x, Toast.LENGTH_LONG).show();
}
};
}
当我运行应用程序并转到aaaaActivity时,应用程序会停止,这有什么问题?我在互联网上搜索,有人告诉我“返回null”有问题,但我不知道如何修改它。
答案 0 :(得分:0)
@Override
protected Dialog onCreateDialog(int id) {
if (id == DIALOG_ID){
return new TimePickerDialog(aaaa.this, kTimePickerListner, hour_x, minute_x, false);
}
return null;
}
试试这种方式
答案 1 :(得分:0)
展示aaaa
的{{1}}活动代码似乎TimePickerDialog
。
确保在OK
文件中声明了aaaa
活动。
<强>的AndroidManifest.xml 强>
AndroidManifest.xml