apollow apollow - 8 months ago 44
Android Question

Getting the textview of the TabLayout's tab

I want to programmatically change a tab's textview programmatically. Is there any way to do this?

There are answers only concerning the old TabHost view, I am using the TabLayout used by Google's Material Design library using android.support.design.widget.TabLayout.

For TabHost:
How to add padding to a tabs label?


With a given tab:

 int wantedTabIndex = 0;
 TextView tv = (TextView)(((LinearLayout)((LinearLayout)mTabLayout.getChildAt(0)).getChildAt(wantedTabIndex)).getChildAt(0));
 tv.setText("Hello world!");