现用了一tabhost,选中某选项时,会跟上一背景图,实现代码如下
tab_indicator.xml
<?xml version="1.0" encoding="UTF-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/tab_unselected" />
<item
android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/onselect"
/></selector>
现需:如果要在选中某选项时,还要再把选中项的文字的颜色变成白色(默认是黑色),
(我在上面的文件中加入android:color 没用)
怎么实现呀 thanks
tab_indicator.xml
<?xml version="1.0" encoding="UTF-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/tab_unselected" />
<item
android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/onselect"
/></selector>
现需:如果要在选中某选项时,还要再把选中项的文字的颜色变成白色(默认是黑色),
(我在上面的文件中加入android:color 没用)
怎么实现呀 thanks
解决方案 »
- 请教:安卓手机如何与单片机通信?
- 再发一贴:问framework里的代码是怎么运行的?
- 能否动态修改include的layout
- android游戏中文字如何描绘
- 【新人学习】Handler 两个构造函数冲突的问题
- android引入jar包导致的classnotfound问题
- 关于java.lang.StackOverflowError的问题求各路朋友和大神指点
- cordova-plugin-audio-recorder-api 的录音总是闪退
- Android Studio3.4安装报错
- 求助!!!
- android的listView有滚动条时(即实际Item数比显示出来的Item数多),点击item变色事件报空指针错
- 请教android使用youtube API问题
android:textColor="@color/tab_textview_color"/>tab_textview_color.xml代码:<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:color="@color/tab_textview_pressed" />
<!-- not selected -->
<item android:color="@color/tab_textview_normal" />
</selector>
tab_textview_pressed tab_textview_normal 颜色值
public void onTabChanged(String tabId) {
//tabId值为要切换到的tab页的索引位置
int tabID = Integer.valueOf(tabId);
for (int i = 0; i < tabWidget.getChildCount(); i++)
{
if (i == tabID)
{
tabWidget.getChildAt(Integer.valueOf(i));
final TextView textView = (TextView) tabWidget.getChildAt(Integer.valueOf(i)).findViewById(R.id.title);
textView.setTextColor(0xffFEFFFF);
}
else
{
tabWidget.getChildAt(Integer.valueOf(i));
final TextView textView = (TextView) tabWidget.getChildAt(Integer.valueOf(i)).findViewById(R.id.title);
textView.setTextColor(0xff767674);
}
}
}
final TextView textView = (TextView) tabWidget.getChildAt(Integer.valueOf(i)).findViewById(R.id.title);R.id.title 是哪的title,