Reputation: 2153
I have a listview that contains diffrent objects . For example { A , B ,B , A , C , etc } If I click on A it s ok to have highlighted on the item , but if I click on B I don t want to have highlight . I ve put clickable = false in the layout of B component but it does not have effect .
Upvotes: 0
Views: 52
Reputation: 53667
Disabling ListView items
You need to override the following methods: in your adapter isEnabled(int position)
and areAllItemsEnabled()
. In isEnabled()
you return true or false depending is list and in areAllItemsEnabled()
return false.
Example
class CustomAdapter extends ArrayAdapter {
public CustomAdapter(
Context context, int textViewResId, CharSequence[] strings) {
super(context, textViewResId, strings);
}
...
....
public boolean areAllItemsEnabled() {
return false;
}
public boolean isEnabled(int position) {
// return false if you want to disable for any element
}
}
Upvotes: 1
Reputation: 21
extends BaseAdapter and implements isEnabled method
@see: android developer reference
Upvotes: 1