I have a TabActivity class which uses Intents to populate the content view. Under certain conditions, I would like to intercept a tab selection event, put up a message dialog, suppress the selected Intent, and revert to the original tab selected.
I want the TabActivity content to remain Intent driven (rather than using Views).
I suspect this may require extension of the LocalActivityManager.
Has anyone ever accomplished this or done a similiar thing?
// simple example of current code:
TabHost tabHost = getTabHost();
TabSpec ts = tabHost.newTabSpec(tag);
ts.setIndicator(tabview);
ts.setContent(new Intent().setClass(this, AHome.class));
tabHost.addTab(ts);
Thanks!
After a little digging into Android's TabHost src, here's a fairly simple solution to the problem. It allows the tab button to be "touched" graphically yet still remain unselected and it prevents any processing of the selected tab (assuming that all the OnTabSelected listeners have been made aware).
Just Extend the TabHost class:
And then change your reference from TabHost to MyTabHost in the XML used for the TabActivity:
One other thing to remember is that if you use TabActivity.getTabHost() in the TabActivity, it will return a MyTabHost. e.g.: