Java Code Examples for android.widget.TabHost#setCurrentTabByTag()

The following examples show how to use android.widget.TabHost#setCurrentTabByTag() . 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 financisto with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    greenRobotBus = GreenRobotBus_.getInstance_(this);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    initialLoad();

    final TabHost tabHost = getTabHost();

    setupAccountsTab(tabHost);
    setupBlotterTab(tabHost);
    setupBudgetsTab(tabHost);
    setupReportsTab(tabHost);
    setupMenuTab(tabHost);

    MyPreferences.StartupScreen screen = MyPreferences.getStartupScreen(this);
    tabHost.setCurrentTabByTag(screen.tag);
    tabHost.setOnTabChangedListener(this);
}
 
Example 2
Source File: FragmentTabsPager.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.fragment_tabs_pager);
    mTabHost = (TabHost)findViewById(android.R.id.tabhost);
    mTabHost.setup();

    mViewPager = (ViewPager)findViewById(R.id.pager);

    mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);

    mTabsAdapter.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
            FragmentStackSupport.CountingFragment.class, null);
    mTabsAdapter.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
            LoaderCursorSupport.CursorLoaderListFragment.class, null);
    mTabsAdapter.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
            LoaderCustomSupport.AppListFragment.class, null);
    mTabsAdapter.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
            LoaderThrottleSupport.ThrottledLoaderListFragment.class, null);

    if (savedInstanceState != null) {
        mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
    }
}
 
Example 3
Source File: MainActivity.java    From android_tv_metro with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    mTabHost = (TabHost)findViewById(android.R.id.tabhost);
    mTabHost.setup();
    mTabs    = (TabWidget)findViewById(android.R.id.tabs);

    ViewStub vStub = (ViewStub) findViewById(R.id.new_home_menu);
    mMenuContainer = (FrameLayout) vStub.inflate();
    mViewPager = (ViewPager)findViewById(R.id.pager);

    mLoadingView = makeEmptyLoadingView(this, (RelativeLayout)findViewById(R.id.tabs_content));

    setScrollerTime(800);

    albumItem = (DisplayItem) getIntent().getSerializableExtra("item");
    setUserFragmentClass();
    getSupportLoaderManager().initLoader(TabsGsonLoader.LOADER_ID, null, this);

    if (savedInstanceState != null) {
        mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
    }
}
 
Example 4
Source File: DocActivityView.java    From Mupdf with Apache License 2.0 6 votes vote down vote up
public void onShowSearch()
{
	//  "deselect" all the visible tabs by selecting the hidden (first) one
	TabHost tabHost = (TabHost)findViewById(R.id.tabhost);
	tabHost.setCurrentTabByTag("HIDDEN");

	//  show search as selected
	showSearchSelected(true);

	//  hide all the other tabs
	hideAllTabs();

	//  show the search tab
	findViewById(R.id.searchTab).setVisibility(View.VISIBLE);
	mSearchText.getText().clear();
}
 
Example 5
Source File: DocActivityView.java    From Mupdf with Apache License 2.0 5 votes vote down vote up
protected void setupTabs()
{
	tabHost = (TabHost) findViewById(R.id.tabhost);
	tabHost.setup();

	//  get the tab tags.
	mTagHidden = getResources().getString(R.string.hidden_tab);
	mTagFile = getResources().getString(R.string.file_tab);
	mTagAnnotate = getResources().getString(R.string.annotate_tab);
	mTagPages = getResources().getString(R.string.pages_tab);

	//  first tab is and stays hidden.
	//  when the search tab is selected, we programmatically "select" this hidden tab
	//  which results in NO tabs appearing selected in this tab host.
	setupTab(tabHost, mTagHidden, R.id.hiddenTab, R.layout.tab);
	tabHost.getTabWidget().getChildTabViewAt(0).setVisibility(View.GONE);

	//  these tabs are shown.
	setupTab(tabHost, mTagFile, R.id.fileTab, R.layout.tab_left);
	setupTab(tabHost, mTagAnnotate, R.id.annotateTab, R.layout.tab);
	setupTab(tabHost, mTagPages, R.id.pagesTab, R.layout.tab_right);

	//  start by showing the edit tab
	tabHost.setCurrentTabByTag(mTagFile);

	tabHost.setOnTabChangedListener(this);
}
 
Example 6
Source File: ActivityLogs.java    From LibreTasks with Apache License 2.0 4 votes vote down vote up
@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 7
Source File: TrackDetailActivity.java    From mytracks with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  hasCamera = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
  photoUri = savedInstanceState != null ? (Uri) savedInstanceState.getParcelable(PHOTO_URI_KEY)
      : null;
  hasPhoto = savedInstanceState != null ? savedInstanceState.getBoolean(HAS_PHOTO_KEY, false)
      : false;
     
  myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
  handleIntent(getIntent());

  sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);

  trackRecordingServiceConnection = new TrackRecordingServiceConnection(
      this, bindChangedCallback);
  trackDataHub = TrackDataHub.newInstance(this);

  tabHost = (TabHost) findViewById(android.R.id.tabhost);
  tabHost.setup();

  viewPager = (ViewPager) findViewById(R.id.pager);

  tabsAdapter = new TabsAdapter(this, tabHost, viewPager);

  TabSpec mapTabSpec = tabHost.newTabSpec(MyTracksMapFragment.MAP_FRAGMENT_TAG).setIndicator(
      getString(R.string.track_detail_map_tab),
      getResources().getDrawable(R.drawable.ic_tab_map));
  tabsAdapter.addTab(mapTabSpec, MyTracksMapFragment.class, null);

  TabSpec chartTabSpec = tabHost.newTabSpec(ChartFragment.CHART_FRAGMENT_TAG).setIndicator(
      getString(R.string.track_detail_chart_tab),
      getResources().getDrawable(R.drawable.ic_tab_chart));
  tabsAdapter.addTab(chartTabSpec, ChartFragment.class, null);

  TabSpec statsTabSpec = tabHost.newTabSpec(StatsFragment.STATS_FRAGMENT_TAG).setIndicator(
      getString(R.string.track_detail_stats_tab),
      getResources().getDrawable(R.drawable.ic_tab_stats));
  tabsAdapter.addTab(statsTabSpec, StatsFragment.class, null);

  if (savedInstanceState != null) {
    tabHost.setCurrentTabByTag(savedInstanceState.getString(CURRENT_TAB_TAG_KEY));
  }
  
  // Set the background after all three tabs are added
  ApiAdapterFactory.getApiAdapter().setTabBackground(tabHost.getTabWidget());
  
  trackController = new TrackController(
      this, trackRecordingServiceConnection, false, recordListener, stopListener);
}
 
Example 8
Source File: DisplayNovelPagerActivity.java    From coolreader with MIT License 4 votes vote down vote up
@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 9
Source File: DisplayAlternativeNovelPagerActivity.java    From coolreader with MIT License 4 votes vote down vote up
@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);

	tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
		public void onTabChanged(String tabId) {
			setTabColor();
			currentActivity = lam.getActivity(tabId);
		}
	});

	/* Dynamically add Tabs */
	ArrayList<String> Choice = new ArrayList<String>();

	Iterator<Entry<String, AlternativeLanguageInfo>> it = AlternativeLanguageInfo.getAlternativeLanguageInfo().entrySet().iterator();
	while (it.hasNext()) {
		AlternativeLanguageInfo info = it.next().getValue();
		boolean isChosen = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(info.getLanguage(), true);
		if (isChosen) {
			Choice.add(info.getLanguage());
			Log.d("Language Added: ", info.getLanguage());
		}
		it.remove();
	}

	TabSpec[] allSpec = new TabSpec[Choice.size()];
	for (int i = 0; i < Choice.size(); i++) {
		allSpec[i] = tabHost.newTabSpec(Choice.get(i));
		allSpec[i].setIndicator(Choice.get(i));
		Intent firstIntent = new Intent(this, DisplayAlternativeNovelListActivity.class);
		firstIntent.putExtra("LANG", Choice.get(i));
		allSpec[i].setContent(firstIntent);

		// Adding all TabSpec to TabHost
		tabHost.addTab(allSpec[i]);

		// Cheap preload list hack.
		tabHost.setCurrentTabByTag(Choice.get(i));
	}

	// Tab color
	setTabColor();
}