本帖最后由 李永康 于 2013-5-29 20:49 编辑
今天学习android,遇到一个问题,始终不是很明白,代码如下:- private static final int DIALOG_DATEPICKER_ID = 1;// 日期对话框ID
- private static final int DIALOG_TIMEPICKER_ID = 2;// 时间对话框ID
复制代码- protected Dialog onCreateDialog(int id) {
- // TODO Auto-generated method stub
- switch (id) {
- case DIALOG_DATEPICKER_ID:
- DatePickerDialog dp = new DatePickerDialog(MainActivity.this,
- dateCallBack, year, monthOfYear, dayOfMonth);
- return dp;
- case DIALOG_TIMEPICKER_ID:
- TimePickerDialog tp = new TimePickerDialog(MainActivity.this,
- timeCallBack, hourOfDay, minute, true);
- return tp;
- }
- return super.onCreateDialog(id);
- }
复制代码 这ID,和onCreateDialog(int Id)方法中的id怎么关联上的?获取Id,一般不是用R.id?这个方法吗?
|