当前位置: 首页>>代码示例>>Java>>正文


Java FragmentTabHost.setCurrentTabByTag方法代码示例

本文整理汇总了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;
	}
 
开发者ID:jackvt93,项目名称:Open-Battery-Saver,代码行数:40,代码来源:OptimizationFragment.java

示例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);

}
 
开发者ID:ColinBin,项目名称:face_detection,代码行数:47,代码来源:HomeTeacher.java

示例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);

}
 
开发者ID:ColinBin,项目名称:face_detection,代码行数:58,代码来源:HomeStudent.java


注:本文中的android.support.v4.app.FragmentTabHost.setCurrentTabByTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。