How to change android tab text on the fly?

后端 未结 7 1720
灰色年华
灰色年华 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:21

    You can do it without knowing the magic index of the TextView by using findViewById:

    TabWidget vTabs = getTabWidget();
    View indicatorView = vTabs.getChildAt(tabIndex);
    ((TextView) indicatorView.findViewById(android.R.id.title)).setText("NewTabText");
    

提交回复
热议问题