grid to list view and vice versa in android
-
12-11-2019 - |
Question
I want to add option in the actionbar to change my record display from grid to list and vice versa. you can see an example here:
ListView
ListView http://cdn.androidblip.com/screens/1____170969.png
GridView
GridView http://cdn.androidblip.com/screens/2____170969.png
So please, is there any open source or example code for that.
Solution
you can do when option is selected call the gridview activity and when list option is selected call the listview activity in one clicklistener
OTHER TIPS
or else based on the selection u can do like this
if(selectedItem == list)
setContentView(R.id.list)
else
setContenView(R.id.grid)
then you can have the same actions performed no need to rewrite the same code
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow