Im building an app with a tab-layout. And i have some concerns about tab-layout in general.
- Tab tabs in an app the are connected in some way but passing data between them how?
- And if you pass data how tell parent host to switch tab?
- I’ve read in a couple of places to not use activities in the tabs but instead use layouts. Why not? I see the tabs as a kind of controller for my view and if i use different layouts in same activity for lets say a “list-view” and a “details” view for some model, my activity will be cluttered with logic for both of them.
For now i have two tabs, one list-view tab display a list of items (DUH!), and one filter tab filtering the items with a button to apply the filter.
When applying the filter i need to filter the items in the list depending on some factor like item title and category. On the button click i send a broadcast intent picked up by the list and tabhost, switching the tab, and changing the list after the filter.
Does this make sense, how do you do it?
//twd
If you want to support the latest and greatest android features, check out the Action Bar. It provides navigation tabs now, which was a weak spot in previous versions. It is very nice, and uses fragments to handle tab content.
If you want a solution that is implemented for prior android versions, check out the ActionBarSherlock library that provides a backwards-compatible action bar.
As for communication between tabs, they are all within the same Activity, so you can simply communicate through your Activity class.