Sorry for my English. Much to learn.
I have a TabActivity in my app. I would like that one of the buttons show a context menu when it is clicked.
I managed to call a method on click one of the tabs. But in the same time the tab calls and activity. This one closes the current one which it doesn't make good impression.
An example:
Adding the tabs to the tabhost
intent = new Intent().setClass(this, NewsActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = tabHost.newTabSpec(TAB_NEWS).setIndicator(getString(R.string.tab_news), res.getDrawable(R.drawable.ic_tab_news)).setContent(intent);
tabHost.addTab(spec);
If I don't pass and intent gives error.
intent = new Intent().setClass(this, NewsActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = tabHost.newTabSpec(TAB_NEWS).setIndicator(getString(R.string.tab_news), res.getDrawable(R.drawable.ic_tab_news)).setContent(intent);
tabHost.addTab(spec);
To Call the method I use the next listener on the tab
tabHost.getChildAt(1).setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
//Somethig to do
e
return false;
}
});
Thank you very much.