wang584 发表于 2013-4-18 15:08
你那个在布局页面上定义的ListView是不是创建成其他的了 - public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);//这个是我自己添加上去的,之后就报错了。
- // 获得ListView
- listView = getListView();
- // 实例化LayoutInflater
- li = getLayoutInflater();
- // 设置ListView Adapter
- listView.setAdapter(new ViewAdapter());
- // 可多选
- listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
- // 获得Calendar实例
- final Calendar c = Calendar.getInstance();
- // 获得当前日期、时间
- mYear = c.get(Calendar.YEAR);
- mMonth = c.get(Calendar.MONTH);
- mDay = c.get(Calendar.DAY_OF_MONTH);
- mHour = c.get(Calendar.HOUR_OF_DAY);
- mMinute = c.get(Calendar.MINUTE);
-
- // 响应列表单击事件
- listView.setOnItemClickListener(new OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> av, View v, int position,
- long id) {
- switch (position) {
- // 设置是否开启提醒
- case 0:
- ctv1 = (CheckedTextView) v;
- if (ctv1.isChecked()) {
- on_off = 0;
- } else {
- on_off = 1;
- }
- break;
- // 设置提醒日期
- case 1:
- showDialog(DATE_DIALOG_ID);
- break;
- // 设置提醒时间
- case 2:
- showDialog(TIME_DIALOG_ID);
- break;
- // 设置提醒内容
- case 3:
- showDialog1("请输入内容:");
- break;
- // 设置是否开启语音提醒
- case 4:
- ctv2 = (CheckedTextView) v;
- if (ctv2.isChecked()) {
- alarm = 0;
- setAlarm(false);
- } else {
- alarm = 1;
- setAlarm(true);
- }
- break;
- default:
- break;
- }
- }
- });
- }
复制代码 |