@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_base_clear_cache); //1.����ѡ�1 TabSpec tab1 = getTabHost().newTabSpec("clear_cache").setIndicator("��������"); // ImageView imageView = new ImageView(this); // imageView.setBackgroundResource(R.drawable.ic_launcher); // View view = View.inflate(this, R.layout.test, null); // TabSpec tab1 = getTabHost().newTabSpec("clear_cache").setIndicator(view); //2.����ѡ�2 TabSpec tab2 = getTabHost().newTabSpec("sd_cache_clear").setIndicator("sd������"); //3.��֪����ѡ��������� tab1.setContent(new Intent(this,CacheClearActivity.class)); tab2.setContent(new Intent(this,SDCacheClearActivity.class)); //4.��������ѡ�ά��host(ѡ�����)��ȥ getTabHost().addTab(tab1); getTabHost().addTab(tab2); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTabHost = (TabHost) findViewById(R.id.edit_item_tab_host); mTabHost.setup(getLocalActivityManager()); TabSpec tabCall = mTabHost.newTabSpec("TAB_Call"); tabCall.setIndicator("电话"); tabCall.setContent(new Intent(this, AnswerCallActivity.class)); mTabHost.addTab(tabCall); TabSpec tabMessage = mTabHost.newTabSpec("TAB_Message"); tabMessage.setIndicator("短信"); tabMessage.setContent(new Intent(this, AnswerMessageActivity.class)); mTabHost.addTab(tabMessage); mTabHost.setCurrentTab(0); }
public void init(FragmentTabHost fragmentTabHost, Activity activity) { this.activity = activity; // 得到fragment的个数 int count = classArray.length; for (int i = 0; i < count; i++) { // 给每个Tab按钮设置图标、文字和内容 TabSpec tabSpec = fragmentTabHost.newTabSpec(labelArray[i]).setIndicator( getTabItemView(i, activity)); // 将Tab按钮添加进Tab选项卡中 fragmentTabHost.addTab(tabSpec, classArray[i], null); // 设置Tab按钮的背景 //mTabHost.getTabWidget().getChildAt(i) // .setBackgroundResource(R.drawable.tt_tab_bk); } this.selectTab(0); fragmentTabHost.setOnTabChangedListener(this); }
@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); } }
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 = inflateView(R.layout.v2_tab_indicator); ImageView icon = (ImageView) indicator.findViewById(R.id.tab_icon); icon.setImageResource(mainTab.getResIcon()); TextView title = (TextView) indicator.findViewById(R.id.tab_titile); 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); } }
/** Creates tab with part of entry related to one language and one part of speech, * runs POS activity. **/ public void createOnePOSTab(TPage _tpage, TLang _tlang, TLangPOS _lang_pos) { Bundle b = new Bundle(); b.putInt("page_id", _tpage.getID()); // pass parameter: TPage by page_id b.putInt("lang_id", _tlang.getID()); // pass parameter: TLang by lang_id b.putInt("lang_pos_id", _lang_pos.getID()); // pass parameter: TLangPOS by lang_pos_id Intent i = new Intent(this, WCPOSActivity.class); i.putExtras(b); //System.out.println("Source activity: page_id = " + _tpage.getID() // + "; lang_id = " + _tlang.getID() // + "; lang_pos_id = " + _lang_pos.getID()); TabSpec _tabspec = tab_host_pos.newTabSpec( "" + _lang_pos.getID() ); // some unique text _tabspec.setIndicator( getShortPOSText(_lang_pos) ); _tabspec.setContent(i); tab_host_pos.addTab(_tabspec); }
/** Creates tab with part of entry related to one language, * runs language activity. **/ public void createOneLanguageTab(TPage _tpage, TLang _tlang) { //TLangPOS _lang_pos) { Bundle b = new Bundle(); b.putInt("page_id", _tpage.getID()); // pass parameter: TPage by page_id b.putInt("lang_id", _tlang.getID()); // pass parameter: TLang by lang_id Intent i = new Intent(this, WCLanguageActivity.class); //Intent i = new Intent().setClass(this, WCLanguageActivity.class); i.putExtras(b); //System.out.println("Source activity: page_id = " + _tpage.getID() + "; lang_id = " + _tlang.getID()); TabSpec _tabspec = tab_host_languages.newTabSpec( "" + _tlang.getID() ); // some unique text LanguageType _lang = _tlang.getLanguage(); _tabspec.setIndicator(_lang.getCode()); _tabspec.setContent(i); tab_host_languages.addTab(_tabspec); }
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); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.file_tab); Resources res = getResources(); // Resource object to get Drawables TabHost tabHost = getTabHost(); // The activity TabHost TabSpec spec; Intent intent; // Reusable Intent for each tab //��һ��TAB intent = new Intent(this,FileActivity.class);//�½�һ��Intent����Tab1��ʾ������ spec = tabHost.newTabSpec("�����ļ�")//�½�һ�� Tab .setIndicator("�����ļ�", res.getDrawable(android.R.drawable.ic_menu_manage))//���������Լ�ͼ�� .setContent(intent);//������ʾ��intent������IJ���Ҳ������R.id.xxx tabHost.addTab(spec);//��ӽ�tabHost //�ڶ���TAB intent = new Intent(this,VDiskFileActivity.class);//�ڶ���Intent����Tab2��ʾ������ spec = tabHost.newTabSpec("��VDisk")//�½�һ�� Tab .setIndicator("��VDisk", res.getDrawable(android.R.drawable.ic_dialog_map))//���������Լ�ͼ�� .setContent(intent);//������ʾ��intent������IJ���Ҳ������R.id.xxx tabHost.addTab(spec);//��ӽ�tabHost tabHost.setCurrentTab(0); }
@SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_tabhost); TabHost tabHost = getTabHost(); TabSpec tabSpec1 = tabHost.newTabSpec("Home"); TabSpec tabSpec2 = tabHost.newTabSpec("Second"); tabSpec1.setIndicator("Home"); tabSpec2.setIndicator("Second"); Intent photosIntent = new Intent(this, GridViewActivity.class); Intent secondactivIntent = new Intent(this, SecondActivity.class); tabSpec1.setContent(photosIntent); tabSpec2.setContent(secondactivIntent); tabHost.addTab(tabSpec1); tabHost.addTab(tabSpec2); }
/** * initializes the pages in the tabbed dialog */ protected void initTabs() { // Setup the tabbed dialog on the layout and add the content of each tab TabHost tabHost = (TabHost) findViewById(R.id.tabHost); tabHost.setup(); TabSpec localTabSpec = tabHost.newTabSpec(localTabString()); localTabSpec.setContent(R.id.localGameTab); localTabSpec.setIndicator(localTabString()); TabSpec remoteTabSpec = tabHost.newTabSpec(remoteTabString()); remoteTabSpec.setContent(R.id.remoteGameTab); remoteTabSpec.setIndicator(remoteTabString()); tabHost.addTab(localTabSpec); tabHost.addTab(remoteTabSpec); // make sure the current tab is the right one tabHost.setCurrentTab(config.isLocal() ? 0 : 1); }
@SuppressLint("InflateParams") private void initTabSpec() { int count = getTabItemCount(); for (int i = 0; i < count; i++) { // set text view View tabItem = mLayoutflater.inflate(R.layout.api_tab_item, null); ImageView tvTabItem = (ImageView) tabItem .findViewById(R.id.tab_item_iv); setTabItemTextView(tvTabItem, i); // set id String tabItemId = getTabItemId(i); // set tab spec TabSpec tabSpec = mTabHost.newTabSpec(tabItemId); tabSpec.setIndicator(tabItem); tabSpec.setContent(getTabItemIntent(i)); mTabHost.addTab(tabSpec); } }
private void initTabs() { mTabHost = (TabHost)mView.findViewById(android.R.id.tabhost); mTabHost.setup(); final TabSpec spec1 = mTabHost.newTabSpec(TAB_TAG_INFO); spec1.setContent(R.id.color_info_view_tab_info); spec1.setIndicator(getString(R.string.color_info_tab_info)); final TabSpec spec2 = mTabHost.newTabSpec(TAB_TAG_SIMILAR); spec2.setContent(R.id.color_info_view_tab_similar); spec2.setIndicator(getString(R.string.color_info_tab_similar)); mTabHost.addTab(spec1); mTabHost.addTab(spec2); }
/** 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); }
@SuppressLint("InflateParams") private TabSpec createTabSpec(TabHost tabHost, String tag, Resources res, int labelId, int iconId, Class<?> cls) { TabSpec spec = tabHost.newTabSpec(tag); String label = res.getString(labelId); Drawable icon = res.getDrawable(iconId); LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.tab, null); ((ImageView) linearLayout.findViewById(R.id.tab_icon)).setImageDrawable(icon); ((TextView) linearLayout.findViewById(R.id.tab_label)).setText(label); spec.setIndicator(linearLayout); spec.setContent(new Intent().setClass(this, cls)); return spec; }
/** * Creates a {@link TabSpec} based on the specified parameters. * @param inflater The {@link LayoutInflater} responsible for creating {@link View}s. * @param tabHost The {@link TabHost} used to create new {@link TabSpec}s. * @param root The root {@link View} for the {@link Fragment}. * @param tabDefinition The {@link TabDefinition} that defines what the tab will look and act like. * @return A new {@link TabSpec} instance. */ private TabSpec createTab(LayoutInflater inflater, TabHost tabHost, View root, TabDefinition tabDefinition) { ViewGroup tabsView = (ViewGroup)root.findViewById(android.R.id.tabs); View tabView = tabDefinition.createTabView(inflater, tabsView); TabSpec tabSpec = tabHost.newTabSpec(tabDefinition.getId()); tabSpec.setIndicator(tabView); tabSpec.setContent(tabDefinition.getTabContentViewId()); return tabSpec; }
@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; }
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; }
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); }
private void initTabView() { // ʵ����tabhost this.tabHost = (TabHost) findViewById(R.id.mytabhost); // ���ڼ̳���ActivityGroup��������Ҫ��setup���������˲��������̳�TabActivity���ʡ�� tabHost.setup(this.getLocalActivityManager()); // ������ǩ for (int i = 0; i < activitys.length; i++) { // ʵ����һ��view��Ϊtab��ǩ�IJ��� View view = View.inflate(this, R.layout.main_tab_layout, null); // ����imageview ImageView imageView = (ImageView) view.findViewById(R.id.image); imageView.setImageDrawable(getResources().getDrawable(image[i])); // ����textview TextView textView = (TextView) view.findViewById(R.id.title); textView.setText(title[i]); // ������תactivity Intent intent = new Intent(this, activitys[i]); // ����view����������ת��activity TabSpec spec = tabHost.newTabSpec(title[i]).setIndicator(view).setContent(intent); // ��ӵ�ѡ� tabHost.addTab(spec); } }
private TabSpec newTab(String tag, int labelId, int tabContentId) { Log.d(TAG, "buildTab(): tag=" + tag); View indicator = LayoutInflater.from(getActivity()).inflate( R.layout.tab, (ViewGroup) mRoot.findViewById(android.R.id.tabs), false); ((TextView) indicator.findViewById(R.id.text)).setText(labelId); TabSpec tabSpec = mTabHost.newTabSpec(tag); tabSpec.setIndicator(indicator); Log.d(tag, tabContentId + " tabContentId " + indicator.getId() + " indicator get Id "); tabSpec.setContent(tabContentId); return tabSpec; }
private void createTabs() { mTabHost.clearAllTabs(); mTabHost.setOnTabChangedListener(null); // or we would get NPEs in onTabChanged() when calling addTab() TabSpec tabSpec1 = mTabHost.newTabSpec(WHEEL_TAG) .setIndicator(mContext.getString(R.string.color_picker_wheel)) .setContent(mFactory); TabSpec tabSpec2 = mTabHost.newTabSpec(EXACT_TAG) .setIndicator(mContext.getString(R.string.color_picker_exact)) .setContent(mFactory); mTabHost.addTab(tabSpec1); mTabHost.addTab(tabSpec2); mTabHost.setOnTabChangedListener(this); String tag = mCurrentTab != null ? mCurrentTab : WHEEL_TAG; mTabHost.setCurrentTabByTag(tag); }
public static void setTabIndicator(TabSpec spec, String title, Drawable drawable) { // if (drawable != null) { // spec.setIndicator(title, drawable); // } else { spec.setIndicator(title); // } }
private static void setTabIndicator(TabSpec spec, String title, Drawable drawable, View view) { int sdk = new Integer(Build.VERSION.SDK).intValue(); if (sdk < 4) { TabsUtil3.setTabIndicator(spec, title, drawable); } else { TabsUtil4.setTabIndicator(spec, view); } }
public static void addTab(TabHost host, String title, int drawable, int index, int layout) { TabHost.TabSpec spec = host.newTabSpec("tab" + index); spec.setContent(layout); View view = prepareTabView(host.getContext(), title, drawable); TabsUtil.setTabIndicator(spec, title, host.getContext().getResources().getDrawable(drawable), view); host.addTab(spec); }
public static void addTab(TabHost host, String title, int drawable, int index, Intent intent) { TabHost.TabSpec spec = host.newTabSpec("tab" + index); spec.setContent(intent); View view = prepareTabView(host.getContext(), title, drawable); TabsUtil.setTabIndicator(spec, title, host.getContext().getResources().getDrawable(drawable), view); host.addTab(spec); }
@SuppressLint("InflateParams") public LabelDialog(Context context) { super(context); tabs = new ArrayList<String>(); tabSpecs = new ArrayList<TabHost.TabSpec>(); setButton(DialogInterface.BUTTON_NEGATIVE, getContext().getResources().getString(R.string.cancel_dialog_button), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // User cancelled the dialog } }); View labelDialogView = getLayoutInflater().inflate(R.layout.label_dialog, null); setView(labelDialogView); tabHost = (TabHost) labelDialogView.findViewById(R.id.label_tabhost); tabHost.setup(); // Hide soft keyboard on tab change tabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { handleTabChange(tabId); } }); }
protected void addTab(String id, String title, TabContentFactory content) { TabHost.TabSpec tab = tabHost.newTabSpec(id); tab.setIndicator(title); tab.setContent(content); tabs.add(id); tabSpecs.add(tab); }
@Override public void show() { if (tabSpecs != null) { for (TabHost.TabSpec tab : tabSpecs) { tabHost.addTab(tab); } tabSpecs = null; } super.show(); }
public TabSpec createTabSpec(TabHost tabHost) { TabSpec tabSpec = tabHost.newTabSpec(name); tabSpec.setContent(new TabContentFactory() { @Override public View createTabContent(String tag) { return view; } }); tabSpec.setIndicator(label); return tabSpec; }
private void setupTab(final View view, final String tag, final Intent myintent) { View tabview = createTabView(mTabHost.getContext(), tag); TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(myintent); try{ mTabHost.addTab(setContent); } catch(Exception ex) { ex.toString(); } }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mesh); Bundle extras = getIntent().getExtras(); if (extras != null) { user = extras.getString("user");//usuario }else{ user="error"; } // create the TabHost that will contain the Tabs TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); TabSpec tab1 = tabHost.newTabSpec("First Tab"); TabSpec tab2 = tabHost.newTabSpec("Second Tab"); TabSpec tab3 = tabHost.newTabSpec("Third tab"); // Set the Tab name and Activity // that will be opened when particular Tab will be selected tab1.setIndicator("Around"); tab1.setContent(new Intent(this,Mesh1.class).putExtra("user",user)); tab2.setIndicator("Mine"); tab2.setContent(new Intent(this,Mesh2.class).putExtra("user",user)); tab3.setIndicator("On"); tab3.setContent(new Intent(this,Mesh3.class).putExtra("user",user)); /** Add the tabs to the TabHost to display. */ tabHost.addTab(tab1); tabHost.addTab(tab2); tabHost.addTab(tab3); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tab); boolean exists; Vector valori = null; /* TabHost will have Tabs */ TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost); /* * TabSpec used to create a new tab. By using TabSpec only we can able * to setContent to the tab. By using TabSpec setIndicator() we can set * name to tab. */ /* tid1 is firstTabSpec Id. Its used to access outside. */ TabSpec firstTabSpec = tabHost.newTabSpec("tid1"); TabSpec secondTabSpec = tabHost.newTabSpec("tid2"); /* TabSpec setIndicator() is used to set name for the tab. */ /* TabSpec setContent() is used to set content for a particular tab. */ firstTabSpec.setIndicator("Interessi").setContent( new Intent(this, TabInteressi.class)); secondTabSpec.setIndicator("Sfida").setContent( new Intent(this, TabSfida.class)); /* Add tabSpec to the TabHost to display. */ tabHost.addTab(firstTabSpec); tabHost.addTab(secondTabSpec); // switch for tab /* * Write write = new Write(valori); exists=write.getexits(); * * if (exists) { tabHost.setCurrentTabByTag("tid2"); } else { * tabHost.setCurrentTabByTag("tid1"); } */ }