Skip to content Skip to sidebar Skip to footer

Disabling And Changing Style Of Individual Listview Items With Custom Adapter In Android

I have a listview that is being populated by information from a database using a custom adapter to handle the individual views. What I am trying to do is disable certain items in t

Solution 1:

Ok I figured this out. The method was as simple as this:

public boolean isEnabled(int position) {

    if (position == 2) {
        return false
    }

    return true;  
}

This has to be set in the custom adapter. Not called from the implementation in the activity. This was the problem since I was trying to do something like mycustomadapter.isEnabled(2) which is incorrect.

Hope this helps someone else.


Solution 2:

but the isEnabled() method basically enables/disables the entire listview, not the individual item.

It will gives the status of the current row.

    public boolean isEnabled(int position) {
    return super.isEnabled(position);
};

but what your trying to do? are you enables/disable by this

(adapter.getView(position, convertView, parent)).setEnabled(false);

Post a Comment for "Disabling And Changing Style Of Individual Listview Items With Custom Adapter In Android"