here’s the code, I have problem with:
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, android.view.View view,
int position, long id) {
if(listview.isItemChecked(position)){
}
if(listview.getCheckedItemCount()>1){
}
}
});
it keeps saying that listener must override superclass method and that I cant call non-final variable “listview” inside inner class. how am I supposed to call listview.isItemChecked(position) then? thanks
I’d suggest you read up on the use of
finalin Java. Technically, you could fix this by adding the keywordfinalbeforeListView listview = ..., sofinal ListView listview = ....However, a better option is to just use the passed reference to ListView in your
OnItemClick-method. The parameterAdapterView<?> Parentcorresponds to your ListView, so you can use the following code: