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

}


05-11 01:13