lolyoshi
lolyoshi

Reputation: 1536

Force not to change tab in Android

I want to force the user change tab when there's not enough my conditions. How can I do that?

I'm using TabHost. When I press another tab, I can force the tab content not change but the I don't know how to set the selected tab in the bottom not change.

Thanks!

My code is something like that

if (condition == true){
   //Can change tab
} else {
   //CAN'T CHANGE TAB
}

Upvotes: 0

Views: 42

Answers (1)

Mario
Mario

Reputation: 145

boolean change;
if (condition == true){
   change=true;
   //Can change tab
} else {
   change=false;
   //CAN'T CHANGE TAB
}
 and in tabchange listener,

 tabHost.setOnTabChangedListener(new OnTabChangeListener() {
            public void onTabChanged(String arg0) {
     if(!change)
        tab.setCurrentTab();

}
});

Upvotes: 1

Related Questions