本文整理匯總了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);
}