List of usage examples for android.widget TabHost addTab
public void addTab(TabSpec tabSpec)
From source file:au.com.wallaceit.reddinator.ViewRedditActivity.java
/** * @param activity;/*from w w w .j a v a2 s .c o m*/ * @param tabHost; * @param tabSpec; */ private static void addTab(ViewRedditActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec, TabInfo tabInfo) { // Attach a Tab view factory to the spec tabSpec.setContent(activity.new TabFactory(activity)); String tag = tabSpec.getTag(); // Check to see if we already have a fragment for this tab, probably // from a previously saved state. If so, deactivate it, because our // initial state is that a tab isn't shown. tabInfo.fragment = activity.getSupportFragmentManager().findFragmentByTag(tag); if (tabInfo.fragment != null && !tabInfo.fragment.isDetached()) { android.support.v4.app.FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); ft.detach(tabInfo.fragment); ft.commit(); activity.getSupportFragmentManager().executePendingTransactions(); } tabHost.addTab(tabSpec); }
From source file:fr.mixit.android.ui.SpeakerDetailActivity.java
/** Build and add "bio" tab. */ private void setupBioTab() { final TabHost host = getTabHost(); // Summary content comes from existing layout host.addTab(host.newTabSpec(TAG_BIO).setIndicator(buildIndicator(R.string.speaker_bio)) .setContent(R.id.tab_speaker_bio)); }
From source file:org.geometerplus.android.fbreader.bookmark.EditBookmarkActivity.java
private void addTab(TabHost host, String id, int content) { final TabHost.TabSpec spec = host.newTabSpec(id); spec.setIndicator(myResource.getResource(id).getValue()); spec.setContent(content);/*from ww w .j a va2 s .c o m*/ host.addTab(spec); }
From source file:com.example.chilipepper.finalgooglemapsproject.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); lv = (ListView) findViewById(R.id.list); TabHost tabHost = (TabHost) findViewById(R.id.tabHost); tabHost.setup();//from ww w . j a va 2 s .c o m TabHost.TabSpec tabSpec = tabHost.newTabSpec("list"); tabSpec.setContent(R.id.tabList); tabSpec.setIndicator("List"); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("Map"); tabSpec.setContent(R.id.tabMap); tabSpec.setIndicator("Map"); tabHost.addTab(tabSpec); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); MapFragment mapFragment = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)); mapFragment.getMapAsync(this); }
From source file:org.videolan.vlc2.gui.AboutFragment.java
private void addNewTab(TabHost tabHost, String tag, String title) { DummyContentFactory dcf = new DummyContentFactory(tabHost.getContext()); TabSpec tabSpec = tabHost.newTabSpec(tag); tabSpec.setIndicator(getNewTabIndicator(tabHost.getContext(), title)); tabSpec.setContent(dcf);//from w w w .j a v a 2 s . c o m tabHost.addTab(tabSpec); }
From source file:ru.gkpromtech.exhibition.events.EventsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // restore saved positions int savedPosition = 0; if (savedInstanceState != null) { savedFilter = savedInstanceState.getInt(SAVE_FILTER, EventReader.EVENT_FILTER_ALL); savedPosition = savedInstanceState.getInt(SAVE_PAGE_NUMBER, 0); } else {/*from www. j a v a 2s.c o m*/ // calculate day to position ViewPager Calendar calendar = Calendar.getInstance(); Date d = calendar.getTime(); List<Date> days = new ArrayList<>(EventReader.getInstance(this).getDays()); if (days.contains(d)) savedPosition = days.indexOf(d); } FrameLayout view = (FrameLayout) findViewById(R.id.container); getLayoutInflater().inflate(R.layout.activity_events, view, true); TabHost tabHost = (TabHost) view.findViewById(R.id.tabHost); tabHost.setup(); tabHost.addTab(tabHost .newTabSpec("tag" + EventReader.EVENT_FILTER_ALL).setIndicator(createIndicatorView(tabHost, getResources().getString(R.string.all_uppercase), R.drawable.ic_events_all)) .setContent(R.id.tab1)); tabHost.addTab(tabHost .newTabSpec("tag" + EventReader.EVENT_FILTER_SHOW).setIndicator(createIndicatorView(tabHost, getResources().getString(R.string.event_status_business), R.drawable.ic_white_plane)) .setContent(R.id.tab2)); tabHost.addTab(tabHost .newTabSpec("tag" + EventReader.EVENT_FILTER_MY).setIndicator(createIndicatorView(tabHost, getResources().getString(R.string.event_status_my), R.drawable.ic_person)) .setContent(R.id.tab3)); pager = (ViewPager) findViewById(R.id.pager); pagerAdapter = new EventsFragmentPagerAdapter(getSupportFragmentManager(), EventReader.getInstance(this), savedFilter); pager.setAdapter(pagerAdapter); // set saved page pager.setCurrentItem(savedPosition); tabHost.setCurrentTabByTag("tag" + savedFilter); pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageScrollStateChanged(int state) { } }); tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { switch (tabId) { case "tag" + EventReader.EVENT_FILTER_ALL: savedFilter = EventReader.EVENT_FILTER_ALL; break; case "tag" + EventReader.EVENT_FILTER_SHOW: savedFilter = EventReader.EVENT_FILTER_SHOW; break; case "tag" + EventReader.EVENT_FILTER_MY: savedFilter = EventReader.EVENT_FILTER_MY; break; } AnalyticsManager.sendEvent(EventsActivity.this, R.string.events_category, R.string.action_change, savedFilter); pagerAdapter.setFilter(savedFilter); } }); AnalyticsManager.sendEvent(this, R.string.events_category, R.string.action_open, savedFilter); }
From source file:org.inftel.ssa.mobile.ui.fragments.ProjectDetailFragment.java
private void setupLinksTab(View view) { TabHost mTabHost = (TabHost) view.findViewById(android.R.id.tabhost); mTabHost.addTab(mTabHost.newTabSpec(TAG_LINKS).setIndicator(buildIndicator(R.string.project_links, view)) .setContent(R.id.tab_project_links)); }
From source file:org.inftel.ssa.mobile.ui.fragments.ProjectDetailFragment.java
private void setupInformationTab(View view) { TabHost mTabHost = (TabHost) view.findViewById(android.R.id.tabhost); mTabHost.addTab(mTabHost.newTabSpec(TAG_INFORMATION) .setIndicator(buildIndicator(R.string.project_information, view)) .setContent(R.id.tab_project_information)); }
From source file:org.inftel.ssa.mobile.ui.fragments.ProjectDetailFragment.java
private void setupDescriptionTab(View view) { TabHost mTabHost = (TabHost) view.findViewById(android.R.id.tabhost); mTabHost.addTab(mTabHost.newTabSpec(TAG_DESCRIPTION) .setIndicator(buildIndicator(R.string.project_description, view)) .setContent(R.id.tab_detail_project_description)); }
From source file:com.simplaapliko.wakeup.sample.ui.DialogDateTime.java
private void initUiWidgets(View rootView) { Log.d(TAG, "initUiWidgets()"); // set up tabhost TabHost tabHost = (TabHost) rootView.findViewById(R.id.tabhost); tabHost.setup();/* ww w.j ava 2 s. c om*/ TabHost.TabSpec tabSpec; // adding tabs tabSpec = tabHost.newTabSpec("date"); tabSpec.setIndicator("Date"); tabSpec.setContent(R.id.date); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("time"); tabSpec.setIndicator("Time"); tabSpec.setContent(R.id.time); tabHost.addTab(tabSpec); TimePicker timePicker = (TimePicker) rootView.findViewById(R.id.time); timePicker.setIs24HourView(true); //set to true, because it is more compact timePicker.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); // init time picker before OnTimeChangedListener() is set // otherwise minutes will be set to current time, once setCurrentHour() is called timePicker.setCurrentHour(mCalendar.get(Calendar.HOUR_OF_DAY)); timePicker.setCurrentMinute(mCalendar.get(Calendar.MINUTE)); timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() { @Override public void onTimeChanged(TimePicker view, int hourOfDay, int minute) { mCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay); mCalendar.set(Calendar.MINUTE, minute); mCalendar.set(Calendar.SECOND, 0); } }); DatePicker datePicker = (DatePicker) rootView.findViewById(R.id.date); datePicker.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); datePicker.init(mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH), new DatePicker.OnDateChangedListener() { @Override public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) { mCalendar.set(Calendar.YEAR, year); mCalendar.set(Calendar.MONTH, monthOfYear); mCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); } }); }