Android: Change Tab Text Color Programmatically

后端 未结 4 1704
星月不相逢
星月不相逢 2020-11-30 09:08

I\'ve a TabHost like this:


 

        
4条回答
  •  旧时难觅i
    2020-11-30 09:23

    When you use findViewById(id) you ask the system to look for any View with the id "id" relatively to the current ViewGroup. That means that what you do in your code is this.findViewById(id), so it will look for "id" in the current View. And doing findViewById(android.R.id.tabHost) is not very smart because it just does not exist...

    When you do getTabHost() however, you ask the system to get the unique tabHost of your activity, no matter it have any View as root, i.e. the tabHost can be attached to nothing upside it.

    As a conclusion, you should always us getTabHost in your TabHostActivity

    Hope I was clear

提交回复
热议问题