Java Code Examples for android.widget.TabHost#TabSpec
The following examples show how to use
android.widget.TabHost#TabSpec .
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: FragmentTabHost.java From adt-leanback-support with Apache License 2.0 | 6 votes |
public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); String tag = tabSpec.getTag(); TabInfo info = new TabInfo(tag, clss, args); if (mAttached) { // If we are already attached to the window, then check to make // sure this tab's fragment is inactive if it exists. This shouldn't // normally happen. info.fragment = mFragmentManager.findFragmentByTag(tag); if (info.fragment != null && !info.fragment.isDetached()) { FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.detach(info.fragment); ft.commit(); } } mTabs.add(info); addTab(tabSpec); }
Example 2
Source File: TabHandler.java From ssj with GNU General Public License v3.0 | 6 votes |
private void checkVisualFeedbackTabs() { List<Component> visualFeedbacks = PipelineBuilder.getInstance().getComponentsOfClass(PipelineBuilder.Type.EventHandler, VisualFeedback.class); removeComponentsOfClass(additionalTabs, VisualFeedback.class); if (!visualFeedbacks.isEmpty()) { boolean anyUnmanaged = false; TableLayout visualFeedbackLayout = getTableLayoutForVisualFeedback(visualFeedbacks); TabHost.TabSpec newTabSpec = getNewTabSpec(visualFeedbackLayout, visualFeedbacks.get(0).getComponentName(), android.R.drawable.ic_menu_compass); // TODO: Change icon. for (Component visualFeedback : visualFeedbacks) { boolean isManaged = PipelineBuilder.getInstance().isManagedFeedback(visualFeedback); if(! isManaged) { anyUnmanaged = true; ((VisualFeedback) visualFeedback).options.layout.set(visualFeedbackLayout); } } if(anyUnmanaged) additionalTabs.put(visualFeedbacks.get(0), newTabSpec); } }
Example 3
Source File: TabHandler.java From ssj with GNU General Public License v3.0 | 6 votes |
private void checkAnnotationTabs() { List<Component> iFileWriters = PipelineBuilder.getInstance().getComponentsOfClass(PipelineBuilder.Type.Consumer, IFileWriter.class); List<Component> trainers = PipelineBuilder.getInstance().getComponentsOfClass(PipelineBuilder.Type.Consumer, Trainer.class); if (iFileWriters.isEmpty() && trainers.isEmpty()) { removeComponentsOfClass(firstTabs, AnnotationTab.class); } else if (!containsOfClass(firstTabs, AnnotationTab.class)) { AnnotationTab annotationTab = new AnnotationTab(activity); TabHost.TabSpec annotationTabSpec = getTabSpecForITab(annotationTab); firstTabs.put(annotationTab, annotationTabSpec); } else //Annotation tab is already here, refresh it { getAnnotation().syncWithModel(); } }
Example 4
Source File: FragmentTabHost.java From V.FlyoutTest with MIT License | 6 votes |
public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); String tag = tabSpec.getTag(); TabInfo info = new TabInfo(tag, clss, args); if (mAttached) { // If we are already attached to the window, then check to make // sure this tab's fragment is inactive if it exists. This shouldn't // normally happen. info.fragment = mFragmentManager.findFragmentByTag(tag); if (info.fragment != null && !info.fragment.isDetached()) { FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.detach(info.fragment); ft.commit(); } } mTabs.add(info); addTab(tabSpec); }
Example 5
Source File: TabHandler.java From ssj with GNU General Public License v3.0 | 5 votes |
private TabHost.TabSpec getNewTabSpec(final View view, String title, int icon) { final TabHost.TabSpec tabSpec = tabHost.newTabSpec(title); tabSpec.setContent(new TabHost.TabContentFactory() { public View createTabContent(String tag) { return view; } }); tabSpec.setIndicator("", ContextCompat.getDrawable(activity, icon)); return tabSpec; }
Example 6
Source File: DocActivityView.java From Mupdf with Apache License 2.0 | 5 votes |
protected void setupTab(TabHost tabHost, String text, int viewId, int tabId) { View tabview = LayoutInflater.from(tabHost.getContext()).inflate(tabId, null); TextView tv = (TextView) tabview.findViewById(R.id.tabText); tv.setText(text); TabHost.TabSpec tab = tabHost.newTabSpec(text); tab.setIndicator(tabview); tab.setContent(viewId); tabHost.addTab(tab); }
Example 7
Source File: HelloTabWidget.java From coursera-android with MIT License | 5 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Resources res = getResources(); // Resource object to get Drawables TabHost tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; // Reusable TabSpec for each tab Intent intent; // Reusable Intent for each tab // Create an Intent to launch an Activity for the tab (to be reused) intent = new Intent().setClass(this, ArtistsActivity.class); // Initialize a TabSpec for each tab and add it to the TabHost spec = tabHost.newTabSpec("artists").setIndicator("Artists", res.getDrawable(R.drawable.ic_tab_artists)) .setContent(intent); tabHost.addTab(spec); // Do the same for the other tabs intent = new Intent().setClass(this, AlbumsActivity.class); spec = tabHost.newTabSpec("albums").setIndicator("Albums", res.getDrawable(R.drawable.ic_tab_albums)) .setContent(intent); tabHost.addTab(spec); intent = new Intent().setClass(this, SongsActivity.class); spec = tabHost.newTabSpec("songs").setIndicator("Songs", res.getDrawable(R.drawable.ic_tab_songs)) .setContent(intent); tabHost.addTab(spec); tabHost.setCurrentTab(2); }
Example 8
Source File: TabsAdapter.java From mytracks with Apache License 2.0 | 5 votes |
public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle bundle) { tabSpec.setContent(new DummyTabFactory(context)); TabInfo info = new TabInfo(clss, bundle); tabInfos.add(info); tabHost.addTab(tabSpec); notifyDataSetChanged(); }
Example 9
Source File: MainActivity.java From iTab with Apache License 2.0 | 5 votes |
private void addTab(String label, String tag, Drawable drawable, int id) { TabHost.TabSpec spec = mTabHost.newTabSpec(tag); spec.setIndicator(createTabIndicator(label, drawable)); spec.setContent(id); mTabHost.addTab(spec); }
Example 10
Source File: HelpFragment.java From RobotCA with GNU General Public License v3.0 | 5 votes |
/** * Adds a tab to this TabsAdapter. * @param tabSpec The TabSpec for the tab * @param clss The class of the Fragment to be contained in the tab * @param args Arguments for the tab */ public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); tabSpec.getTag(); TabInfo info = new TabInfo(clss, args); mTabs.add(info); mTabHost.addTab(tabSpec); notifyDataSetChanged(); }
Example 11
Source File: MainActivity.java From enjoyshop with Apache License 2.0 | 5 votes |
private void initTab() { Tab tab_home = new Tab(HomeFragment.class, R.string.home, R.drawable.selector_icon_home); Tab tab_hot = new Tab(HotFragment.class, R.string.hot, R.drawable.selector_icon_hot); Tab tab_category = new Tab(CategoryFragment.class, R.string.catagory, R.drawable .selector_icon_category); Tab tab_shop = new Tab(ShopCartFragment.class, R.string.cart, R.drawable .selector_icon_cart); Tab tab_mine = new Tab(MineFragment.class, R.string.mine, R.drawable.selector_icon_mine); mTabs.add(tab_home); mTabs.add(tab_hot); mTabs.add(tab_category); mTabs.add(tab_shop); mTabs.add(tab_mine); mInflater = LayoutInflater.from(this); mTabhost = (FragmentTabHost) this.findViewById(android.R.id.tabhost); mTabhost.setup(this, getSupportFragmentManager(), R.id.realtabcontent); for (Tab tab : mTabs) { TabHost.TabSpec tabSpec = mTabhost.newTabSpec(getString(tab.getTitle())); tabSpec.setIndicator(buildIndicator(tab)); mTabhost.addTab(tabSpec, tab.getFragment(), null); } mTabhost.getTabWidget().setShowDividers(LinearLayout.SHOW_DIVIDER_NONE); mTabhost.setCurrentTab(0); //默认选中第0个 }
Example 12
Source File: EmojiPalettesView.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
private void addTab(final TabHost host, final int categoryId) { final String tabId = EmojiCategory.getCategoryName(categoryId, 0 /* categoryPageId */); final TabHost.TabSpec tspec = host.newTabSpec(tabId); tspec.setContent(R.id.emoji_keyboard_dummy); final ImageView iconView = (ImageView)LayoutInflater.from(getContext()).inflate( R.layout.emoji_keyboard_tab_icon, null); // TODO: Replace background color with its own setting rather than using the // category page indicator background as a workaround. iconView.setBackgroundColor(mCategoryPageIndicatorBackground); iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId)); iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId)); tspec.setIndicator(iconView); host.addTab(tspec); }
Example 13
Source File: TabsAdapter.java From callerid-for-android with GNU General Public License v3.0 | 5 votes |
public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); String tag = tabSpec.getTag(); TabInfo info = new TabInfo(tag, clss, args); mTabs.add(info); mTabHost.addTab(tabSpec); notifyDataSetChanged(); }
Example 14
Source File: MainActivity.java From AndroidCacheFoundation with Apache License 2.0 | 5 votes |
private void showTabs() { initTabInfo(); tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.setOnTabChangedListener(this); tabHost.setup(); viewPager = (MyViewPager) findViewById(R.id.viewpager); viewPager.setOffscreenPageLimit(5); viewPager.setAdapter(new TabAdapter(this, viewPager, tabInfos)); viewPager.setSwipeEnabled(false); for (TabInfo tabInfo : tabInfos) { TabHost.TabSpec tabSpec = tabHost.newTabSpec(tabInfo.getId()); tabSpec.setIndicator(tabInfo.getIndicatorView()); tabSpec.setContent(new TabHost.TabContentFactory() { @Override public View createTabContent(String arg0) { View v = new View(MainActivity.this); v.setMinimumWidth(0); v.setMinimumHeight(0); return v; } }); tabHost.addTab(tabSpec); } }
Example 15
Source File: PlaybackActivity.java From android-vlc-remote with GNU General Public License v3.0 | 5 votes |
private void addTab(String tag, int label, int icon) { TabHost.TabSpec spec = mTabHost.newTabSpec(tag); spec.setContent(new TabFactory(this)); spec.setIndicator(getText(label), getResources().getDrawable(icon)); mTabHost.addTab(spec); mTabSpecList.add(spec); }
Example 16
Source File: WizardActivity.java From CameraV with GNU General Public License v3.0 | 4 votes |
public void initLayout() { pager = new TabPager(getSupportFragmentManager()); tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.setup(); tabHost.setOnTabChangedListener(pager); viewPager.setAdapter(pager); viewPager.setOnPageChangeListener(pager); viewPager.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); TabHost.TabSpec tabSpec = null; @SuppressWarnings("unused") View indicator = null; int i = 1; for(Fragment f : fragments) { tabSpec = tabHost.newTabSpec(f.getClass().getSimpleName()) .setIndicator(indicator = new Indicator(String.valueOf(i), this).tab) .setContent(new TabHost.TabContentFactory() { @Override public View createTabContent(String tag) { View view = new View(WizardActivity.this); view.setMinimumHeight(0); view.setMinimumWidth(0); return view; } }); tabHost.addTab(tabSpec); i++; } if(getIntent().hasExtra(Codes.Extras.CHANGE_LOCALE)) { getIntent().removeExtra(Codes.Extras.CHANGE_LOCALE); viewPager.setCurrentItem(1); } }
Example 17
Source File: AbstractCommentFragment.java From Plumble with GNU General Public License v3.0 | 4 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = LayoutInflater.from(getActivity()); View view = inflater.inflate(R.layout.dialog_comment, null, false); mCommentView = (WebView) view.findViewById(R.id.comment_view); mCommentEdit = (EditText) view.findViewById(R.id.comment_edit); mTabHost = (TabHost) view.findViewById(R.id.comment_tabhost); mTabHost.setup(); if(mComment == null) { mCommentView.loadData("Loading...", null, null); requestComment(mProvider.getService()); } else { loadComment(mComment); } TabHost.TabSpec viewTab = mTabHost.newTabSpec("View"); viewTab.setIndicator(getString(R.string.comment_view)); viewTab.setContent(R.id.comment_tab_view); TabHost.TabSpec editTab = mTabHost.newTabSpec("Edit"); editTab.setIndicator(getString(isEditing() ? R.string.comment_edit_source : R.string.comment_view_source)); editTab.setContent(R.id.comment_tab_edit); mTabHost.addTab(viewTab); mTabHost.addTab(editTab); mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { if("View".equals(tabId)) { // When switching back to view tab, update with user's HTML changes. mCommentView.loadData(mCommentEdit.getText().toString(), "text/html", "UTF-8"); } else if("Edit".equals(tabId) && "".equals(mCommentEdit.getText().toString())) { // Load edittext content for the first time when the tab is selected, to improve performance with long messages. mCommentEdit.setText(mComment); } } }); mTabHost.setCurrentTab(isEditing() ? 1 : 0); AlertDialog.Builder adb = new AlertDialog.Builder(getActivity()); adb.setView(view); if (isEditing()) { adb.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { editComment(mProvider.getService(), mCommentEdit.getText().toString()); } }); } adb.setNegativeButton(R.string.close, null); return adb.create(); }
Example 18
Source File: ActivityLogs.java From LibreTasks with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_logs); Resources res = getResources(); // Resource object to get Drawables TabHost tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; // Resusable TabSpec for each tab Intent intent; // Reusable Intent for each tab // Add All Logs tab intent = new Intent().setClass(this, ActivityLogTabs.class); intent.putExtra(ActivityLogTabs.KEY_INTENT_LOG_TYPE, ActivityLogTabs.KEY_ALL_LOGS); spec = tabHost.newTabSpec(TAB_TAG_ALL_LOG).setIndicator(getString(R.string.All), res.getDrawable(R.drawable.icon_log_all_small)).setContent(intent); tabHost.addTab(spec); // Add Event Logs tab intent = new Intent().setClass(this, ActivityLogTabs.class); intent.putExtra(ActivityLogTabs.KEY_INTENT_LOG_TYPE, ActivityLogTabs.KEY_EVENT_LOGS); spec = tabHost.newTabSpec(TAB_TAG_EVENT_LOG).setIndicator(getString(R.string.Events), res.getDrawable(R.drawable.icon_event_unknown_small)).setContent(intent); tabHost.addTab(spec); // Add Action Logs tab intent = new Intent().setClass(this, ActivityLogTabs.class); intent.putExtra(ActivityLogTabs.KEY_INTENT_LOG_TYPE, ActivityLogTabs.KEY_ACTION_LOGS); spec = tabHost.newTabSpec(TAB_TAG_ACTION_LOG).setIndicator(getString(R.string.Actions), res.getDrawable(R.drawable.icon_action_unknown_small)).setContent(intent); tabHost.addTab(spec); // Add General Logs tab intent = new Intent().setClass(this, ActivityLogTabs.class); intent.putExtra(ActivityLogTabs.KEY_INTENT_LOG_TYPE, ActivityLogTabs.KEY_GENERAL_LOGS); spec = tabHost.newTabSpec(TAB_TAG_GENERAL_LOG).setIndicator(getString(R.string.General), res.getDrawable(R.drawable.icon_log_general_small)).setContent(intent); tabHost.addTab(spec); String tabTag = getIntent().getStringExtra(KEY_TAB_TAG); if (tabTag == null) { tabHost.setCurrentTabByTag(TAB_TAG_ALL_LOG); } else { Log.w("LOGS", "tabTag is "+ tabTag); tabHost.setCurrentTabByTag(tabTag); } }
Example 19
Source File: MainActivity.java From OpenMemories-Tweak with MIT License | 4 votes |
protected void addTab(String tag, String label, int iconId, Class activity) { TabHost.TabSpec tab = getTabHost().newTabSpec(tag); tab.setIndicator(label, getResources().getDrawable(iconId)); tab.setContent(new Intent(this, activity)); getTabHost().addTab(tab); }