码迷,mamicode.com
首页 > 其他好文 > 详细

tabhost改变标签颜色

时间:2017-07-26 13:46:01      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:lis   oid   package   getc   text   lda   ret   resource   inf   

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));
}
}
}*/



}


tabhost改变标签颜色

标签:lis   oid   package   getc   text   lda   ret   resource   inf   

原文地址:http://www.cnblogs.com/yuxuan007/p/7238980.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!