Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable a tab in android screen?

hi can you tell me how to disable a tab in the UI of android code.. (eclair code)

like image 418
garima Avatar asked Dec 21 '10 07:12

garima


2 Answers

If you mean to disable one tab button on TabWidget, then try this code:

// tabHost = ... (get TabHost) tabHost.getTabWidget().getChildTabViewAt(your_index).setEnabled(false); 

If you want to disable tab widget in overall, then:

// tabWidget = ... (get TabWidget)     tabWidget.setEnabled(false); 

Read SDK Help for references:

  • TabHost
  • TabWidget
like image 193
Sergey Glotov Avatar answered Sep 22 '22 18:09

Sergey Glotov


Extend TabHost and override methods:

@Override
public void setCurrentTab(int currentTab) {
    if (currentTab != 2)  // position of the tab that should not get selected
        super.setCurrentTab(currentTab);
    else
        // in my case I want to trigger something here but I don't want the button to get selected
}

@Override
public void setCurrentTabByTag(String tag) {
    if (!"\"plus_tab\"".equals(tag))  // tag of the tab that should not get selected
        super.setCurrentTabByTag(tag);
    else
        // in my case I want to trigger something here but I don't want the button to get selected
}
like image 34
Emil Banca Avatar answered Sep 23 '22 18:09

Emil Banca