如何设置FragmentTabHost
标签文本颜色。我尝试了以下代码,但是没有用。
((TextView) mTabHost.getCurrentTabView()
.findViewById(android.R.id.title)).setTextColor(0xFFFFFFFF);
它给 NPE 说它找不到TextView
.
如何设置FragmentTabHost
标签文本颜色。我尝试了以下代码,但是没有用。
((TextView) mTabHost.getCurrentTabView()
.findViewById(android.R.id.title)).setTextColor(0xFFFFFFFF);
它给 NPE 说它找不到TextView
.
这有点棘手。我使用了以下代码,它对我有用。
for (int i = 0; i < tabhost.getTabWidget().getChildCount(); i++) {
final TextView tv = (TextView) tabhost.getTabWidget().getChildAt(i)
.findViewById(android.R.id.title);
// Look for the title view to ensure this is an indicator and not a divider.(I didn't know, it would return divider too, so I was getting an NPE)
if (tv == null)
continue;
else
tv.setTextColor(0xFFFFFFFF);
}
let's try this :
for example when you add your tab make your Indicator :
TextView view = ....
vew.setTextColor(...)
然后 setIndicator 与您的自定义视图:
mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator(view),
FragmentStackSupport.CountingFragment.class, null);