Set title in child blocks

How do I change the title from a child of a tab? I tried a simple setTitle (...) but it doesn't work.

(from the parent tab activity, however, ...)

thanks, Ori

+2


a source to share


3 answers


Actually I got it to work like this: In TabActvitiy, override: onChildTitleChanged ().



This method is called when the child activity calls setTitle (). from there you can change the title of the screen.

+6


a source


There is no API to change tabs after creation - sorry!



+2


a source


I know that if you add tabs dynamically, you can use ts.setIndicator ("MY TAB!");

... So:

myTabHost = (TabHost)this.findViewById(R.id.th_set_menu_tabhost); 
myTabHost.setup();

ls1 = new ListView(Main_screen.this);       
TabSpec ts1 = myTabHost.newTabSpec("TAB_TAG_1");
ts1.setIndicator("Tab1");
ts1.setContent(new TabHost.TabContentFactory(){
    public View createTabContent(String tag)
    {                                   
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(Main_screen.this,android.R.layout.simple_list_item_1,new String[]{"item1","item2","item3"});
        ls1.setAdapter(adapter);    
        return ls1;
    }       
});
myTabHost.addTab(ts1);

      

here xml if you need it

 <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="64dip" />

 <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"
      android:paddingTop="64dip">  

      <ListView
          android:id = "@+id/danhsach"
          android:layout_width="fill_parent" 
          android:layout_height="fill_parent" />

 </FrameLayout> 

      

0


a source







All Articles