博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
tabhost改变标签颜色
阅读量:4625 次
发布时间:2019-06-09

本文共 2197 字,大约阅读时间需要 7 分钟。

package uiframe.zyx.uiframe.com.uiframe.fragments; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TabHost; import android.widget.TextView; import uiframe.zyx.uiframe.com.uiframe.R; import static uiframe.zyx.uiframe.com.uiframe.R.id.tab1; /**  * Created by DELL on 2017-07-06.  */ public class OneFragment extends Fragment{
private View view; private TabHost mTabHost; private TextView mTextView; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_one,null); // init(); mTabHost = (TabHost) view.findViewById(android.R.id.tabhost); mTextView = (TextView) view.findViewById(android.R.id.title); mTabHost.setup(); inflater.inflate(R.layout.ceshi,mTabHost.getTabContentView()); inflater.inflate(R.layout.ceshi,mTabHost.getTabContentView()); mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator("MAC采集").setContent(tab1)); mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator("黑名单").setContent(R.id.tab2)); /* mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
@Override public void onTabChanged(String tabId) {
// upDateTab(mTabHost); } });*/ return view; } /** * 更新文字颜色。 * * @param mTabHost */ /*private void upDateTab(TabHost mTabHost) {
for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {
TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); if (mTabHost.getCurrentTab() == i) {//选中 tv.setTextColor(this.getResources().getColor(R.color.sys_skin)); } else {//不选中 tv.setTextColor(this.getResources().getColor(R.color.sys_black)); } } }*/ }
 
 

转载于:https://www.cnblogs.com/yuxuan007/p/7238980.html

你可能感兴趣的文章
localStorage之本地储存
查看>>
Archlinux 交换左Ctrl和Cap键
查看>>
#openstack故障处理汇总
查看>>
搜索旋转排序数组 II
查看>>
20、docker swarm
查看>>
psp工具软件前景与范围文档
查看>>
day06-三元表达式
查看>>
C# DateTime.Now详细用法
查看>>
Php中"{}"大括号的用法总结(转)
查看>>
JavaScript内存优化
查看>>
BZOJ1059: [ZJOI2007]矩阵游戏(二分图匹配)
查看>>
P3385 【模板】负环
查看>>
URI、URL 和 URN的区别
查看>>
根据表达式序列(前缀、中缀、后缀)构建表达式树
查看>>
mysql性能优化
查看>>
【SqlServer系列】语法定义符号解析
查看>>
Color Length UVA - 1625
查看>>
TLS/SSL
查看>>
zoj2319Beautiful People Dp
查看>>
图片加载 背景色块问题
查看>>