Reputation: 511
The following code stops working when I add an if else statement. The commented code works when uncommented, but adding the if statement does not show the "Checked" in the listview item. Any help would be greatly appreciated.
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();
}
}
Upvotes: 1
Views: 42
Reputation: 3408
You need to use this:
if(listView.isItemChecked(position)){
//logic
}else{
//other logic
}
Upvotes: 1