本文整理汇总了Java中android.support.v4.app.FragmentTabHost.setCurrentTabByTag方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentTabHost.setCurrentTabByTag方法的具体用法?Java FragmentTabHost.setCurrentTabByTag怎么用?Java FragmentTabHost.setCurrentTabByTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.FragmentTabHost
的用法示例。
在下文中一共展示了FragmentTabHost.setCurrentTabByTag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//mTabHost = (TabHost) rootView.findViewById(android.R.id.tabhost);
//mTabHost.setup();
mTabHost = new FragmentTabHost(getActivity());
mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.pager);
//mViewPager = (ViewPager) mTabHost.findViewById(R.id.pager);
/* mTabsAdapter = new OptimizationPagerAdapter(getActivity(), getChildFragmentManager(), mTabHost, mViewPager);
mTabsAdapter.addTab(mTabHost.newTabSpec(TAB_MODE).setIndicator(getString(R.string.mode)),
ModeTabFragment.class, null);
mTabsAdapter.addTab(mTabHost.newTabSpec(TAB_SMART).setIndicator(getString(R.string.smart)),
SmartTabFragment.class, null);*/
mTabHost.addTab(mTabHost.newTabSpec(TAB_MODE).setIndicator(getString(R.string.mode)),
ModeTabFragment.class, null);
mTabHost.addTab(mTabHost.newTabSpec(TAB_SMART).setIndicator(getString(R.string.smart)),
SmartTabFragment.class, null);
for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {
TextView tabTitle = (TextView) mTabHost.getTabWidget()
.getChildAt(i).findViewById(android.R.id.title);
tabTitle.setTextSize(16f);
mTabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tab_indicator_ab);
}
if (savedInstanceState != null) {
if (savedInstanceState.containsKey(CURRENT_TAB)) {
mTabHost.setCurrentTabByTag(savedInstanceState.getString(CURRENT_TAB));
}
}
return mTabHost;
}
示例2: onCreate
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home_teacher);
Intent intent = getIntent();
teacherNumber = intent.getStringExtra("teacher_number");
Bundle bundle = new Bundle();
bundle.putString("teacher_number", teacherNumber);
// 1.��ʼ��tabHost
tabhost = (FragmentTabHost) findViewById(android.R.id.tabhost);
tabhost.setup(this, getSupportFragmentManager(),
R.id.activity_home_container);
// 2.�½�TabSpec
TabSpec spec = tabhost.newTabSpec(ADD_COURSE);
spec.setIndicator(ADD_COURSE);
addCourseIndictor = new TabIndictorView(this);
spec.setIndicator(addCourseIndictor);
addCourseIndictor.setTabTitle("��ӿγ�");
addCourseIndictor.setTabIcon(R.drawable.new_released,
R.drawable.new_focused);
// 3.���TabSpec
tabhost.addTab(spec, AddCourseFragment.class, bundle);
// 2.�½�TabSpec
spec = tabhost.newTabSpec(SELECT_COURSE);
spec.setIndicator(SELECT_COURSE);
selectCourseIndictor = new TabIndictorView(this);
spec.setIndicator(selectCourseIndictor);
selectCourseIndictor.setTabTitle("�γ̿���");
selectCourseIndictor.setTabIcon(R.drawable.course_released,
R.drawable.course_focused);
// 3.���TabSpec
tabhost.addTab(spec, CourseTeacherFragment.class, bundle);
// ȥ���ָ���
tabhost.getTabWidget().setDividerDrawable(android.R.color.white);
tabhost.setCurrentTabByTag(ADD_COURSE);
addCourseIndictor.setTabSelected(true);
// ����л��¼�,����tabhost��ѡ���¼�;
tabhost.setOnTabChangedListener(this);
}
示例3: onCreate
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home_student);
Intent intent = getIntent();
studentNumber = intent.getStringExtra("student_number");
Bundle bundle = new Bundle();
bundle.putString("student_number", studentNumber);
// 1.��ʼ��tabHost
tabhost = (FragmentTabHost) findViewById(android.R.id.tabhost);
tabhost.setup(this, getSupportFragmentManager(),
R.id.activity_home_container);
// 2.�½�TabSpec
TabSpec spec = tabhost.newTabSpec(SELECT_COURSE);
spec.setIndicator(SELECT_COURSE);
selectCourseIndictor = new TabIndictorView(this);
spec.setIndicator(selectCourseIndictor);
selectCourseIndictor.setTabTitle("����γ�");
selectCourseIndictor.setTabIcon(R.drawable.list_released,
R.drawable.list_focused);
// 3.���TabSpec
tabhost.addTab(spec, CourseStudentFragment.class, bundle);
// 2.�½�TabSpec
spec = tabhost.newTabSpec(ATTENDANCE_RECORD);
spec.setIndicator(ATTENDANCE_RECORD);
attendanceRecordIndictor = new TabIndictorView(this);
spec.setIndicator(attendanceRecordIndictor);
attendanceRecordIndictor.setTabTitle("���ڼ�¼");
attendanceRecordIndictor.setTabIcon(R.drawable.record_released,
R.drawable.record_focused);
// 3.���TabSpec
tabhost.addTab(spec, AttendanceCheckFragment.class, bundle);
// 2.�½�TabSpec
spec = tabhost.newTabSpec(FACE_DETECT);
spec.setIndicator(FACE_DETECT);
faceDetectIndictor = new TabIndictorView(this);
spec.setIndicator(faceDetectIndictor);
faceDetectIndictor.setTabTitle("������ȡ");
faceDetectIndictor.setTabIcon(R.drawable.face_released,
R.drawable.face_focused);
// 3.���TabSpec
tabhost.addTab(spec, CollectFaceDataFragment.class, bundle);
// ȥ���ָ���
tabhost.getTabWidget().setDividerDrawable(android.R.color.white);
tabhost.setCurrentTabByTag(SELECT_COURSE);
selectCourseIndictor.setTabSelected(true);
// ����л��¼�,����tabhost��ѡ���¼�;
tabhost.setOnTabChangedListener(this);
}