Kevin
Kevin

Reputation: 509

Disable item focus in ListView

How can I disable the focus from an Item in a ListView when I click on it, so that there is no focus on click?

Upvotes: 7

Views: 11374

Answers (5)

Silambarasan Poonguti
Silambarasan Poonguti

Reputation: 9442

Try this...

add this snippet to your Adapter class.

@Override
public boolean isEnabled(int position) {
    if (position == 3) { // 3 is the disable list item here.
        return false;
    }
    return true;
}

Upvotes: 0

Deepak Sharma
Deepak Sharma

Reputation: 5073

Just override a simple method in your class which extends the BaseAdapter.This will definitely help you.Please don't forget to upvote.Enjoy.. :)

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

Upvotes: 2

Vineet Shukla
Vineet Shukla

Reputation: 24031

override below method to disable/enable list rows...

@Override
public boolean isEnabled(int position) {
    //Write your code here......
    return super.isEnabled(position);
}

Upvotes: 2

Nikola Despotoski
Nikola Despotoski

Reputation: 50588

Try using listview.setItemsCanFocus(false) this will disable items gaining focus at all.

Upvotes: 2

Lalit Poptani
Lalit Poptani

Reputation: 67296

Here is your answer for disabling the focus of ListView. Override isEnabled(int position) method in your Adapter and return false.

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

Upvotes: 17

Related Questions