How to change android tab text on the fly?

后端 未结 7 1737
灰色年华
灰色年华 2021-01-04 01:42

This seems like it should be simple, but I can\'t figure out a way to do it. I\'m needing a tab to have beginning text, but then have that text change after the user selects

7条回答
  •  梦谈多话
    2021-01-04 02:26

    You can do it like this

    TabHost tabHost = getTabHost();
    TextView tv = (TextView) tabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title);
    tv.setText("New Tab Text");
    

    Where android.R.id.title is System generated, just change ChildIndex and Text according to your need

提交回复
热议问题