fhucho
fhucho

Reputation: 34550

Can I make a ListView item not selectable?

I am implementing an endless ListView (like in the Twitter app). I want to make the last item not selecteble. So that if the penultimate item is selected and I scroll down with my trackball, nothing happens. I tried setting android:focusable="false" and android:cickable="false" but I didn't notice any chnage.

Upvotes: 37

Views: 19642

Answers (3)

Amir Dora.
Amir Dora.

Reputation: 2717

if you're using custom array adapter just override this method.

@Override
public boolean isEnabled(int position) {
    return false;
}

Upvotes: 3

skr1p7k1dd
skr1p7k1dd

Reputation: 109

If you want to get the same effect without having to have a custom adapter, you make the OnClickListener ignore that item when tapped and then set a solid background color for the item's view, so it doesn't highlight when tapped.

Upvotes: 0

Romain Guy
Romain Guy

Reputation: 98521

It's pretty easy, in your adapter you can override the method isEnabled(int position) and return false for this item.

Upvotes: 97

Related Questions