zoukankan      html  css  js  c++  java
  • tabhost改变标签颜色

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



    }


  • 相关阅读:
    Read Table Binary Search读得field一定要按照Sort的顺序
    Retail Article Master Data 学习 (三) Reference Handling 和 Deviation
    像QQ一样的,好用的Navbar
    sql 脚本执行类
    Page.RegisterRequiresRaiseEvent()与Page.RegisterRequiresPostBack()方法
    ASP.Net实现文件的在线压缩和解压缩
    Word maker! 最大流dinic
    POJ 3258 River Hopscotch 二分查找
    C/C++浮点数在内存中的存储方式《转》
    opencv图像处理8卷积
  • 原文地址:https://www.cnblogs.com/yuxuan007/p/7238980.html
Copyright © 2011-2022 走看看