I have been trying to solve this issue now for longer than I care to admit. I'm looking to set up an onClicklistener
for my tabs so even if a user is on that tab and they click it the tab reloads. Could someone please point out my error, below is the code i'm using made up from examples from stack overflow so thanks so far! I'm using the getTabHost().setCurrentTab(3)
to set it to be run only on the tab 3 but how would I get it so that it calls the specific tab the user clicks on?
I have been using this as a reference: OnClickListener on Tabs not working
public class DamTabs extends TabActivity implements OnClickListener{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
Intent intent = new Intent(this, Featured.class);
tabHost.addTab(tabHost.newTabSpec("Tab 1")
.setIndicator("Featured", res.getDrawable(R.drawable.ic_tab_main))
.setContent(intent));
Intent intent2 = new Intent(this, Deals.class);
tabHost.addTab(tabHost.newTabSpec("Tab 2")
.setIndicator("Deals", res.getDrawable(R.drawable.ic_tab_setup))
.setContent(intent2));
Intent intent3 = new Intent(this, Events.class);
tabHost.addTab(tabHost.newTabSpec("Tab 3")
.setIndicator("Events", res.getDrawable(R.drawable.ic_tab_setup))
.setContent(intent3));
getTabWidget().getChildAt(3).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (getTabHost().getCurrentTabTag().equals(sort)) {
getTabHost().setCurrentTab(3);
}
}
});
} //End of onCreate