Reputation: 9238
I'm using the Navigation Drawer Example downloadable here.
I'd like to extend this example to disable the selection of one of the planets. For simplicity, lets say I want to permanently disable the selection of Saturn, and change the text of Saturn to dark gray, and have it not highlight when a user selects it. (in reality, I would like to disable navigation programmatically when a user has changed certain values on the screen not yet saved to the device).
The closest thing I've gotten to this is to stop the selectItem()
method from being called from within the onItemClick
click listener, but an issue remains even if I do this - the text of "Saturn" still appears selectable and highlights when a user clicks it.
What portion of the widgets do I need to change to prevent the text of Saturn from being highlighted?
I've tried changing
mDrawerLayout.setClickable(false);
mDrawerList.setClickable(false);
But neither of these options appear to have any affect.
Any suggestions or ideas as to how to approach this problem? A couple helpful notes:
Upvotes: 1
Views: 3600
Reputation: 1006614
I'd like to extend this example to disable the selection of one of the planets
Create your own subclass of ArrayAdapter
where you override areAllItemsEnabled()
to return false
and isEnabled()
to return true
or false
as needed.
Upvotes: 4