Reputation: 3592
I want to show a finite list of items in a list, each item should contain a subject and an associated drawable and associated action/actionId.
When the user clicks on item something should happen but each item has a different action.
Item 1 - Icon1 + Title1 --> Action1
Item 2 - Icon2 + Title2 --> Action2
Item 3 - Icon3 ...
Item 4 - Icon4 ...
A RecyclerView or ListView will be too heavy for such purpose and also, as usually ListView and Recycler View displays a list of some Model data, I couldn't figure out what will be the model in my case.
Again, all the items in my list are final and well known.
In addition, I need to be able to remove/disable or add/enable items according to a condition
if(condition){
Item3.setVisiability(Visibile)
Item3.setEnabled(true)
}else{
Item3.setVisiability(Gone)
Item3.setEnabled(false)
}
The above description is very similar to a menu correct? A menu gives all the above benefits straight forward
The problem is that a I want to show such menu in a standard container like LinearLayout and as far as I know, menus in Android can be inflated only in spacial places such as: Action menu will be create in onCreateOptionMenu()
and the menu will be shown when click on the 3 dots icon or something like this. This comes of course with a callback for menu action clicks on onOptionItemSelected(Menu item)
right?
What I need, is a menu behavior that always be shown on screen but with all menu benefits! It will be inflated from some menu xml, each item will have it's icon, id, and title, A callback for click actions with the id of the clicked item etc'..
Something like, MenuActivity that will show this menu persistently.
Is this possible in Android? If not, what can be the recommended pattern for such requirement?
Upvotes: 0
Views: 889
Reputation: 1825
build the list in a vertical LinearLayout in a ScrollView. inflate each row's view, bind the view, attach click listener to the view.
Upvotes: 1