android.widget.TabHost.TabContentFactory Java Examples
The following examples show how to use
android.widget.TabHost.TabContentFactory.
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: 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); } }