Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 338
fhucho Avatar asked Feb 26 '11 11:02

fhucho


2 Answers

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

like image 126
Romain Guy Avatar answered Oct 11 '22 22:10

Romain Guy


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

@Override
public boolean isEnabled(int position) {
    return false;
}
like image 36
Amir Dora. Avatar answered Oct 11 '22 20:10

Amir Dora.