Tab Switching using Menu Options in Android
Switching between tabs in Android at times is a problem. Lets say you are in a situation, where you want one activity to switch to another tab. Unlike the iPhone where this would be solved using a parent controller setting the TabHost into the controller. In Android we do not have control on the creation of the Activity. We just create the Intent Object and call the startActivity(intent). In case of Tabs, its even worse, we just create the tabSpec and add it to the TabHost object.
The solution to the above problem is simple. Create an Interface to abstract the TabActivity from the child Activites which does the job of switching. Extend the Intent class to take the ITabSwitcher interface object. This reference can be retrieved on the onCreate method of the child class.
All the source code is here
Labels: Android, menu Options, switching, Tabs
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home