In my android application I have 3 tabs. Each of these 3 tabs have got listviews. Now I have registered these listviews for a contextual menu. How do i detect the tab (id or its name) from which the Contextual menu was instantiated? because all the three listviews from the tabs are registered for same contextual menu.
When a tab get selected you can save the current Tab into a variable, then when an item get selected you can use this value.
private String mCurrentTab;
public MyTabActivity(){
this.getTabHost().setOnTabChangedListener(new OnTabChangeListener(){
@Override
public void onTabChanged(String tabId){
mCurrentTab = tabId;
}
});
.
.
.
}
public getCurrentTab(){
return mCurrentTab;
}
Note, that the TabActivity has been deprecated since ICS (4.0) so you may consider, use Fragments instead,