Java Code Examples for android.widget.TabHost.TabSpec#setContent()
The following examples show how to use
android.widget.TabHost.TabSpec#setContent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LauncherActivity.java From android-apps with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher); TabHost tabHost = getTabHost(); TabSpec tab1 = tabHost.newTabSpec("First Tab"); TabSpec tab2 = tabHost.newTabSpec("Second Tab"); TabSpec tab3 = tabHost.newTabSpec("Third Tab"); tab1.setIndicator("Tab1",getResources().getDrawable(R.drawable.ic_launcher)); tab1.setContent(new Intent(this, Tab1Activity.class)); tab2.setIndicator("Tab2",getResources().getDrawable(R.drawable.ic_launcher)); tab2.setContent(new Intent(this, Tab2Activity.class)); tab3.setIndicator("Tab3",getResources().getDrawable(R.drawable.ic_launcher)); tab3.setContent(new Intent(this, Tab3Activity.class)); tabHost.addTab(tab1); tabHost.addTab(tab2); tabHost.addTab(tab3); }
Example 2
Source File: LauncherActivity.java From android-apps with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher); TabHost tabHost = getTabHost(); TabSpec tab1 = tabHost.newTabSpec("First Tab"); TabSpec tab2 = tabHost.newTabSpec("Second Tab"); TabSpec tab3 = tabHost.newTabSpec("Third Tab"); tab1.setIndicator("Tab1",getResources().getDrawable(R.drawable.ic_launcher)); tab1.setContent(new Intent(this, Tab1Activity.class)); tab2.setIndicator("Tab2",getResources().getDrawable(R.drawable.ic_launcher)); tab2.setContent(new Intent(this, Tab2Activity.class)); tab3.setIndicator("Tab3",getResources().getDrawable(R.drawable.ic_launcher)); tab3.setContent(new Intent(this, Tab3Activity.class)); tabHost.addTab(tab1); tabHost.addTab(tab2); tabHost.addTab(tab3); }
Example 3
Source File: GestionAlumnos.java From android with GNU General Public License v2.0 | 6 votes |
private void cargaPestanas() { Resources res = getResources(); TabHost tabHost = (TabHost) findViewById(R.id.tabhost); tabHost.setup(); TabSpec tbListadoAlumnos = tabHost.newTabSpec(res.getString(R.string.listado_alumnos_title)); tbListadoAlumnos.setContent(R.id.tab1); tbListadoAlumnos.setIndicator(res.getString(R.string.listado_alumnos_title), res.getDrawable(android.R.drawable.ic_menu_slideshow)); tabHost.addTab(tbListadoAlumnos); TabSpec tbNuevoAlumno = tabHost.newTabSpec(res.getString(R.string.nuevo_alumno_title)); tbNuevoAlumno.setContent(R.id.tab2); tbNuevoAlumno.setIndicator(res.getString(R.string.nuevo_alumno_title), res.getDrawable(android.R.drawable.ic_menu_edit)); tabHost.addTab(tbNuevoAlumno); tabHost.setCurrentTab(0); tabHost.setOnTabChangedListener(this); }
Example 4
Source File: TabTest.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tab); TabHost host = (TabHost)findViewById(android.R.id.tabhost); TabSpec spec = host.newTabSpec("tab1"); spec.setContent(R.id.tab1); spec.setIndicator("Button1"); host.addTab(spec); spec = host.newTabSpec("tab2"); spec.setContent(R.id.tab2); spec.setIndicator("Next Button"); host.addTab(spec); spec = host.newTabSpec("tab3"); spec.setContent(R.id.tab3); spec.setIndicator("Just some text"); host.addTab(spec); }
Example 5
Source File: FragmentTabHost.java From letv with Apache License 2.0 | 5 votes |
public void addTab(TabSpec tabSpec, Class<?> clss, Bundle args) { tabSpec.setContent(new DummyTabFactory(this.mContext)); String tag = tabSpec.getTag(); TabInfo info = new TabInfo(tag, clss, args); if (this.mAttached) { info.fragment = this.mFragmentManager.findFragmentByTag(tag); if (!(info.fragment == null || info.fragment.isDetached())) { FragmentTransaction ft = this.mFragmentManager.beginTransaction(); ft.detach(info.fragment); ft.commit(); } } this.mTabs.add(info); addTab(tabSpec); }
Example 6
Source File: MainActivity.java From FragmentMixViewPager with Apache License 2.0 | 5 votes |
private void initTabs() { MainTab[] tabs = MainTab.values(); final int size = tabs.length; for (int i = 0; i < size; i++) { MainTab mainTab = tabs[i]; TabSpec tab = mTabHost.newTabSpec(getString(mainTab.getResName())); View indicator = LayoutInflater.from(getApplicationContext()) .inflate(R.layout.tab_indicator, null); TextView title = (TextView) indicator.findViewById(R.id.tab_title); Drawable drawable = this.getResources().getDrawable( mainTab.getResIcon()); title.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); title.setText(getString(mainTab.getResName())); tab.setIndicator(indicator); tab.setContent(new TabContentFactory() { @Override public View createTabContent(String tag) { return new View(MainActivity.this); } }); mTabHost.addTab(tab, mainTab.getClz(), null); mTabHost.getTabWidget().getChildAt(i).setOnTouchListener(this); } }
Example 7
Source File: QoSTestDetailPagerFragment.java From open-rmbt with Apache License 2.0 | 5 votes |
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View v = inflater.inflate(R.layout.result_tabhost_pager, container, false); tabHost = (TabHost) v.findViewById(android.R.id.tabhost); tabHost.setup(); tabHost.setOnTabChangedListener(this); for (int i = 0; i < pagerAdapter.getCount(); i++) { TabSpec tab = tabHost.newTabSpec(String.valueOf(i)); //tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]); tab.setContent(android.R.id.tabcontent); View indicator = inflater.inflate(R.layout.tabhost_indicator, null); TextView title = (TextView) indicator.findViewById(android.R.id.title); title.setText(pagerAdapter.getPageTitle(i)); tab.setIndicator(indicator); tabHost.addTab(tab); } viewPager = (ExtendedViewPager) v.findViewById(R.id.pager); viewPager.setAdapter(pagerAdapter); viewPager.setOnPageChangeListener(this); setCurrentPosition(0); scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview); viewPager.setCurrentItem(initPageIndex); return v; }
Example 8
Source File: RMBTResultPagerFragment.java From open-rmbt with Apache License 2.0 | 5 votes |
private View createView(View v, LayoutInflater inflater, int currentPage) { tabHost = (TabHost) v.findViewById(android.R.id.tabhost); tabHost.setup(); tabHost.setOnTabChangedListener(this); for (int i = 0; i < pagerAdapter.getCount(); i++) { TabSpec tab = tabHost.newTabSpec(String.valueOf(i)); //tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]); tab.setContent(android.R.id.tabcontent); View indicator = inflater.inflate(R.layout.tabhost_indicator, null); TextView title = (TextView) indicator.findViewById(android.R.id.title); title.setText(getActivity().getResources().getStringArray(R.array.result_page_title)[RMBTResultPagerAdapter.RESULT_PAGE_TAB_TITLE_MAP.get(i)]); if (MAP_INDICATOR_DYNAMIC_VISIBILITY) { if (i == RMBTResultPagerAdapter.RESULT_PAGE_MAP) { indicator.setVisibility(View.GONE); } } tab.setIndicator(indicator); tabHost.addTab(tab); } scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview); viewPager = (ExtendedViewPager) v.findViewById(R.id.pager); viewPager.setAdapter(pagerAdapter); viewPager.setOnPageChangeListener(this); setCurrentPosition(currentPage); return v; }
Example 9
Source File: DrMIPSActivity.java From drmips with GNU General Public License v3.0 | 4 votes |
/** * Creates/places the tabs in the Tabhost. */ private void createTabs() { tabHost = (TabHost)findViewById(android.R.id.tabhost); tabHost.setup(); TabSpec tabCode = tabHost.newTabSpec("tabCode"); tabCode.setIndicator(getString(R.string.code)); tabCode.setContent(R.id.tabCode); tabHost.addTab(tabCode); txtCode = (EditText)findViewById(R.id.txtCode); lblFilename = (TextView)findViewById(R.id.lblFilename); txtCode.addTextChangedListener(new CodeEditorTextWatcher()); TabSpec tabAssembledCode = tabHost.newTabSpec("tabAssembledCode"); tabAssembledCode.setIndicator(getString(R.string.assembled)); tabAssembledCode.setContent(R.id.tabAssembledCode); tabHost.addTab(tabAssembledCode); tblAssembledCode = (TableLayout)findViewById(R.id.tblAssembledCode); cmbAssembledCodeFormat = (Spinner)findViewById(R.id.cmbAssembledCodeFormat); cmbAssembledCodeFormat.setOnItemSelectedListener(spinnersListener); cmbAssembledCodeFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.ASSEMBLED_CODE_FORMAT_PREF, DrMIPS.DEFAULT_ASSEMBLED_CODE_FORMAT)); TabSpec tabDatapath = tabHost.newTabSpec("tabDatapath"); tabDatapath.setIndicator(getString(R.string.datapath)); tabDatapath.setContent(R.id.tabDatapath); tabHost.addTab(tabDatapath); lblCPUFilename = (TextView)findViewById(R.id.lblCPUFilename); cmdStep = (ImageButton)findViewById(R.id.cmdStep); datapathScroll = (HorizontalScrollView)findViewById(R.id.datapathScroll); boolean performanceMode = DrMIPS.getApplication().getPreferences().getBoolean(DrMIPS.PERFORMANCE_MODE_PREF, DrMIPS.DEFAULT_PERFORMANCE_MODE); lblDatapathFormat = (TextView)findViewById(R.id.lblDatapathFormat); cmbDatapathFormat = (Spinner)findViewById(R.id.cmbDatapathFormat); cmbDatapathFormat.setOnItemSelectedListener(spinnersListener); cmbDatapathFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.DATAPATH_DATA_FORMAT_PREF, DrMIPS.DEFAULT_DATAPATH_DATA_FORMAT)); lblDatapathFormat.setVisibility(performanceMode ? View.GONE : View.VISIBLE); cmbDatapathFormat.setVisibility(performanceMode ? View.GONE : View.VISIBLE); lblDatapathPerformance = (TextView)findViewById(R.id.lblDatapathPerformance); cmbDatapathPerformance = (Spinner)findViewById(R.id.cmbDatapathPerformance); cmbDatapathPerformance.setOnItemSelectedListener(spinnersListener); cmbDatapathPerformance.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.PERFORMANCE_TYPE_PREF, DrMIPS.DEFAULT_PERFORMANCE_TYPE)); lblDatapathPerformance.setVisibility(!performanceMode ? View.GONE : View.VISIBLE); cmbDatapathPerformance.setVisibility(!performanceMode ? View.GONE : View.VISIBLE); tblExec = (TableLayout)findViewById(R.id.tblExec); tblExecRow = (TableRow)findViewById(R.id.tblExecRow); TabSpec tabRegisters = tabHost.newTabSpec("tabRegisters"); tabRegisters.setIndicator(getString(R.string.registers)); tabRegisters.setContent(R.id.tabRegisters); tabHost.addTab(tabRegisters); tblRegisters = (TableLayout)findViewById(R.id.tblRegisters); cmbRegistersFormat = (Spinner)findViewById(R.id.cmbRegistersFormat); cmbRegistersFormat.setOnItemSelectedListener(spinnersListener); cmbRegistersFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.REGISTER_FORMAT_PREF, DrMIPS.DEFAULT_REGISTER_FORMAT)); TabSpec tabDataMemory = tabHost.newTabSpec("tabDataMemory"); tabDataMemory.setIndicator(getString(R.string.data_memory)); tabDataMemory.setContent(R.id.tabDataMemory); tabHost.addTab(tabDataMemory); tblDataMemory = (TableLayout)findViewById(R.id.tblDataMemory); cmbDataMemoryFormat = (Spinner)findViewById(R.id.cmbDataMemoryFormat); cmbDataMemoryFormat.setOnItemSelectedListener(spinnersListener); cmbDataMemoryFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.DATA_MEMORY_FORMAT_PREF, DrMIPS.DEFAULT_DATA_MEMORY_FORMAT)); }
Example 10
Source File: DisplayNovelPagerActivity.java From coolreader with MIT License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { UIHelper.SetTheme(this, R.layout.activity_display_novel_pager); UIHelper.SetActionBarDisplayHomeAsUp(this, true); setContentView(R.layout.activity_display_novel_pager); } else { UIHelper.SetTheme(this, R.layout.activity_display_novel_pager_fix); UIHelper.SetActionBarDisplayHomeAsUp(this, true); setContentView(R.layout.activity_display_novel_pager_fix); } tabHost = (TabHost) findViewById(android.R.id.tabhost); lam = new LocalActivityManager(this, false); lam.dispatchCreate(savedInstanceState); tabHost.setup(lam); isInverted = UIHelper.getColorPreferences(this); // First Tab - Normal Novels TabSpec firstSpec = tabHost.newTabSpec(MAIN_SPEC); firstSpec.setIndicator(MAIN_SPEC); Intent firstIntent = new Intent(this, DisplayLightNovelListActivity.class); firstIntent.putExtra(Constants.EXTRA_ONLY_WATCHED, false); firstSpec.setContent(firstIntent); // Second Tab - Teasers TabSpec secondSpec = tabHost.newTabSpec(TEASER_SPEC); secondSpec.setIndicator(TEASER_SPEC); Intent secondIntent = new Intent(this, DisplayTeaserListActivity.class); secondSpec.setContent(secondIntent); // Third Tab - Original TabSpec thirdSpec = tabHost.newTabSpec(ORIGINAL_SPEC); thirdSpec.setIndicator(ORIGINAL_SPEC); Intent thirdIntent = new Intent(this, DisplayOriginalListActivity.class); thirdSpec.setContent(thirdIntent); // Adding all TabSpec to TabHost tabHost.addTab(firstSpec); // Adding First tab tabHost.addTab(secondSpec); // Adding Second tab tabHost.addTab(thirdSpec); // Adding third tab //setTabColor(); tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { public void onTabChanged(String tabId) { //setTabColor(); currentActivity = lam.getActivity(tabId); } }); // Cheap preload list hack. tabHost.setCurrentTabByTag(TEASER_SPEC); tabHost.setCurrentTabByTag(ORIGINAL_SPEC); tabHost.setCurrentTabByTag(MAIN_SPEC); Log.d(TAG, "Created"); }
Example 11
Source File: QoSCategoryPagerFragment.java From open-rmbt with Apache License 2.0 | 4 votes |
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { if (savedInstanceState != null && savedInstanceState.containsKey(BUNDLE_QOS_RESULTS)) { try { setQoSResult(new QoSServerResultCollection(new JSONArray(savedInstanceState.getString(BUNDLE_QOS_RESULTS)))); setDetailType(DetailType.valueOf(savedInstanceState.getString(BUNDLE_DETAIL_TYPE))); } catch (JSONException e) { //e.printStackTrace(); } } //DetailType detailType = DetailType.valueOf(args.getString(ARG_DETAIL_TYPE)); pagerAdapter = new QoSCategoryPagerAdapter((RMBTMainActivity) getActivity(), handler, results); View v = inflater.inflate(R.layout.result_tabhost_pager, container, false); tabHost = (TabHost) v.findViewById(android.R.id.tabhost); tabHost.setup(); tabHost.setOnTabChangedListener(this); for (int i = 0; i < pagerAdapter.getCount(); i++) { TabSpec tab = tabHost.newTabSpec(String.valueOf(i)); //tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]); tab.setContent(android.R.id.tabcontent); View indicator = inflater.inflate(R.layout.tabhost_indicator, null); TextView title = (TextView) indicator.findViewById(android.R.id.title); title.setText(pagerAdapter.getPageTitle(i)); tab.setIndicator(indicator); tabHost.addTab(tab); } viewPager = (ExtendedViewPager) v.findViewById(R.id.pager); viewPager.setAdapter(pagerAdapter); viewPager.setOnPageChangeListener(this); setCurrentPosition(0); scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview); if (initPosition != null) { viewPager.setCurrentItem(initPosition); } return v; }
Example 12
Source File: WebRTCDemo.java From webrtc-app-mono with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate"); super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); populateCameraOrientations(); setContentView(R.layout.tabhost); IntentFilter receiverFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG); receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().compareTo(Intent.ACTION_HEADSET_PLUG) == 0) { int state = intent.getIntExtra("state", 0); Log.v(TAG, "Intent.ACTION_HEADSET_PLUG state: " + state + " microphone: " + intent.getIntExtra("microphone", 0)); if (voERunning) { routeAudio(state == 0 && cbEnableSpeaker.isChecked()); } } } }; registerReceiver(receiver, receiverFilter); mTabHost = getTabHost(); // Main tab mTabSpecVideo = mTabHost.newTabSpec("tab_video"); mTabSpecVideo.setIndicator("Main"); mTabSpecVideo.setContent(R.id.tab_video); mTabHost.addTab(mTabSpecVideo); // Shared config tab mTabHost = getTabHost(); mTabSpecConfig = mTabHost.newTabSpec("tab_config"); mTabSpecConfig.setIndicator("Settings"); mTabSpecConfig.setContent(R.id.tab_config); mTabHost.addTab(mTabSpecConfig); TabSpec mTabv; mTabv = mTabHost.newTabSpec("tab_vconfig"); mTabv.setIndicator("Video"); mTabv.setContent(R.id.tab_vconfig); mTabHost.addTab(mTabv); TabSpec mTaba; mTaba = mTabHost.newTabSpec("tab_aconfig"); mTaba.setIndicator("Audio"); mTaba.setContent(R.id.tab_aconfig); mTabHost.addTab(mTaba); int childCount = mTabHost.getTabWidget().getChildCount(); for (int i = 0; i < childCount; i++) { mTabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 50; } orientationListener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) { public void onOrientationChanged (int orientation) { if (orientation != ORIENTATION_UNKNOWN) { currentDeviceOrientation = orientation; compensateCameraRotation(); } } }; orientationListener.enable (); // Create a folder named webrtc in /scard for debugging webrtcDebugDir = Environment.getExternalStorageDirectory().toString() + webrtcName; File webrtcDir = new File(webrtcDebugDir); if (!webrtcDir.exists() && webrtcDir.mkdir() == false) { Log.v(TAG, "Failed to create " + webrtcDebugDir); } else if (!webrtcDir.isDirectory()) { Log.v(TAG, webrtcDebugDir + " exists but not a folder"); webrtcDebugDir = null; } startMain(); if (AUTO_CALL_RESTART_DELAY_MS > 0) startOrStop(); }
Example 13
Source File: PermissionsDialog.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.permissions_list); LayoutParams params = getWindow().getAttributes(); params.width = LayoutParams.FILL_PARENT; params.height = LayoutParams.FILL_PARENT; getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); mPermissionDetails = (TextView) findViewById(R.id.permission_detail); mPermissionDetails.setMovementMethod(LinkMovementMethod.getInstance()); userPermissionsList = (ListView) findViewById(R.id.user_permissions_list); friendPermissionsList = (ListView) findViewById(R.id.friend_permissions_list); extendedPermissionsList = (ListView) findViewById(R.id.extended_permissions_list); userPermissionsAdapter = new PermissionsListAdapter(user_permissions); userPermissionsList.setAdapter(userPermissionsAdapter); friendPermissionsAdapter = new PermissionsListAdapter(friend_permissions); friendPermissionsList.setAdapter(friendPermissionsAdapter); extendedPermissionAdapter = new PermissionsListAdapter(extended_permissions); extendedPermissionsList.setAdapter(extendedPermissionAdapter); TabHost tabHost = (TabHost) findViewById(R.id.tabHost); tabHost.setup(); TabSpec spec1 = tabHost.newTabSpec("Tab 1"); spec1.setIndicator(activity.getString(R.string.user)); spec1.setContent(R.id.user_permissions_list); TabSpec spec2 = tabHost.newTabSpec("Tab 2"); spec2.setIndicator(activity.getString(R.string.friend)); spec2.setContent(R.id.friend_permissions_list); TabSpec spec3 = tabHost.newTabSpec("Tab 3"); spec3.setIndicator(activity.getString(R.string.extended)); spec3.setContent(R.id.extended_permissions_list); tabHost.addTab(spec1); tabHost.addTab(spec2); tabHost.addTab(spec3); tabHost.setCurrentTab(0); tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = TAB_HEIGHT; tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = TAB_HEIGHT; tabHost.getTabWidget().getChildAt(2).getLayoutParams().height = TAB_HEIGHT; mGetPermissions = (Button) findViewById(R.id.get_permissions_button); mGetPermissions.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /* * Source Tag: perms_tag Call authorize to get the new * permissions */ if (reqPermVector.isEmpty() && Utility.mFacebook.isSessionValid()) { Toast.makeText(activity.getBaseContext(), "No Permissions selected.", Toast.LENGTH_SHORT).show(); PermissionsDialog.this.dismiss(); } else { String[] permissions = reqPermVector.toArray(new String[0]); Utility.mFacebook.authorize(activity, permissions, new LoginDialogListener()); } } }); }