ListView复选框不会检查选择

时间:2015-11-30 19:52:57

标签: java android

添加if else语句时,以下代码停止工作。注释代码在取消注释时有效,但添加if语句不会显示" Checked"在listview项目中。任何帮助将不胜感激。

public void onListItemClick(ListView parent, View view,int position,long id){

    //Toast.makeText(this, events[position] + " Alarm Set ",Toast.LENGTH_LONG).show();
    if(view!=null){
        Toast.makeText(this, events[position] + "Invalid email",Toast.LENGTH_LONG).show();
    }else{
        Toast.makeText(this, events[position] +"Please check your email!",Toast.LENGTH_LONG).show();

    }
}

1 个答案:

答案 0 :(得分:1)

你需要使用它:

if(listView.isItemChecked(position)){
 //logic
}else{
 //other logic
}