How To Make An Item In A List View Non Clickable In Android
How to make the items in a list view not click able. i got topics and items in a list view but the view is same for both topics and items. the items are click able but the topic is
Solution 1:
Don't know if you still need it, but you can implement your own Adapter and override the method isEnabled(int position). Depending on the ViewType of the item you will return true or false.
Solution 2:
Sharing my experience, the following did the trick (view refers to the list item view):
view.setEnabled(false);
view.setOnClickListener(null);
- enabling by overriding the method didn't work as the method was never invoked.
- setting focusable to false didn't work as well.
Solution 3:
To make the items in a list non-clickable, you have to make the adapter return false on its isEnabled
method for the items in the list. An easy way to instantiate an adapter and override isEnabled
can be done in the following way:
SimpleCursorAdapteradapter=newSimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null, from, to, 0) {
@OverridepublicbooleanisEnabled(int position) {
returnfalse;
}
};
Solution 4:
This is the correct answer:
I've found a lot of comments saying that
setEnabled(false)
setClickable(false)
setFocusable(false)
would work, but the answer is NO
The only workaround for this approach is doing:
view= inflater.inflate(R.layout.row_storage_divider, parent, false);
view.setOnClickListener(null);
Solution 5:
Set listSelector transparent in ListView
android:listSelector="@android:color/transparent"
Post a Comment for "How To Make An Item In A List View Non Clickable In Android"