本文整理汇总了Java中android.support.v4.app.FragmentTabHost.newTabSpec方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentTabHost.newTabSpec方法的具体用法?Java FragmentTabHost.newTabSpec怎么用?Java FragmentTabHost.newTabSpec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.FragmentTabHost
的用法示例。
在下文中一共展示了FragmentTabHost.newTabSpec方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main);
tabHost =(FragmentTabHost) findViewById(R.id.fth_main);
tabHost.setup(getApplication(), getSupportFragmentManager(), R.id.fl_main);
for (int i = 0; i < 5; i++) {
TabSpec tab = tabHost.newTabSpec(i+"");
View view = LayoutInflater.from(this).inflate(R.layout.menu, null);
ImageView ivType = (ImageView) view.findViewById(R.id.iv_iconType);
TextView tvName = (TextView) view.findViewById(R.id.tv_name);
ivType.setImageResource(ResUtils.menuIds[i]);
tvName.setText(ResUtils.menuStrs[i]);
tab.setIndicator(view);
Bundle b = new Bundle();
b.putInt("position", i);
tabHost.addTab(tab, MenuFragment.class, b);
}
}
示例2: initView
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
private void initView() {
mLayoutInflater = LayoutInflater.from(this);
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
int count = mFragmentArray.length;
for (int i = 0; i < count; i++) {
TabSpec spec = mTabHost.newTabSpec(getString(mTextArray[i]));
spec.setIndicator(getTabItemView(i));
mTabHost.addTab(spec, mFragmentArray[i], null);
// mTabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tab_item_backgound_selector);
mTabHost.getTabWidget().setDividerDrawable(null);
}
}
示例3: initView
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
private void initView() {
//测试栏目的题目统计TextView
mCount = (TextView) findViewById(R.id.tv_count);
mDoubleClickExit = new DoubleClickExitHelper(this);
Indicator[] indicators = Indicator.values();
mFragmentTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mFragmentTabHost.setup(getApplicationContext(), getSupportFragmentManager(), R.id.realtabcontent);
//初始化Tab
for (int i = 0; i < indicators.length; i++){
TabHost.TabSpec tabSpec = mFragmentTabHost.newTabSpec(getString(indicators[i].getResName()));
tabSpec.setIndicator(getIndicatorView(indicators[i]));
mFragmentTabHost.addTab(tabSpec, indicators[i].getClz(), null);
}
//去除底部按钮之间的分割线
if (android.os.Build.VERSION.SDK_INT > 10) {
mFragmentTabHost.getTabWidget().setShowDividers(0);
mFragmentTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
if(tabId.equals(getString(Indicator.TEST.getResName()))){
mCount.setVisibility(View.VISIBLE);
}else{
mCount.setVisibility(View.GONE);
}
}
});
}}
示例4: onCreate
import android.support.v4.app.FragmentTabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// turn screen on and lock
{
this.getWindow()
.addFlags(
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
// may be replaced with `shell input keyevent 26`
WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK
| PowerManager.ACQUIRE_CAUSES_WAKEUP, "turn screen on");
wl.acquire();
}
init();
setContentView(R.layout.starter_layout);
tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
tabWidget = (TabWidget) findViewById(android.R.id.tabs);
tabHost.setup(this, getSupportFragmentManager(),
android.R.id.tabcontent);
{
test = tabHost.newTabSpec(TEST_TAG);
test.setIndicator("Test");
tabHost.addTab(test, TestFragment.class, null);
}
{
results = tabHost.newTabSpec(RESULTS_TAG);
results.setIndicator("Results");
tabHost.addTab(results, ResultsFragment.class, null);
}
}
示例5: 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);
}
示例6: 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);
}