android vertical tabs
I have to implement vertically aligned tabs (ie. one below another) at the right of the screen (to serve as some sort of the bookmarks). This has to be done for vertical orientation of the device only. From what I've read on SO, it is not easy to modify an existing TabHost and all the given开发者_如何学JAVA examples refer to horizontal orientation of the device. I've decided the easiest way would be to create a ListView, and make each "tab" just an element in the list. In onItemClick method, I handle navigation and change the background color of the clicked item so it appears as selected. I've created a separate xml file for this and include it in every other xml file I have. So, instead of having tabs serving as a host to my activities, my every activity serves as a host to tabs.. this doesn't seem like a very neat solution. is there a better way to implement this?
Personally I would use the Android Compatibility Library and fragments to do this. You can design your sidebar using a vertical layout of buttons and just switch the content area (a fragment) when needed.
You can read more about fragments here
精彩评论