List of usage examples for android.widget TabHost getTabWidget
public TabWidget getTabWidget()
From source file:Main.java
public static int getTabCount(TabHost tabHost) { return tabHost.getTabWidget().getTabCount(); }
From source file:com.esminis.server.library.dialog.about.AboutViewImpl.java
private void setupTabTitles(TabHost tabhost) { final int tabCount = tabhost.getTabWidget() == null ? 0 : tabhost.getTabWidget().getTabCount(); for (int i = 0; i < tabCount; i++) { View viewTab = tabhost.getTabWidget().getChildTabViewAt(i); if (viewTab != null) { View textView = viewTab.findViewById(android.R.id.title); if (textView != null && textView instanceof TextView) { ((TextView) textView).setGravity(Gravity.CENTER); }/*from www. ja v a 2 s . com*/ viewTab.setBackgroundResource(R.drawable.tab_indicator); } } }
From source file:com.org.icsfoodapp.OrderTabsPagerFragmentActivity.java
private void update(final TabHost tabHost) { for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) { View view = tabHost.getTabWidget().getChildAt(i); TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); //tv.setTextSize(16); tv.setTextColor(this.getResources().getColorStateList(android.R.color.white)); }/* www .ja va2 s .c o m*/ }
From source file:info.papdt.blacklight.support.Utility.java
public static void initDarkTabHost(Activity activity, TabHost tabhost) { if (isDarkMode(activity)) { int textColor = 0; try {// w w w .ja v a 2 s .c om TypedArray array = activity.getTheme().obtainStyledAttributes(R.styleable.BlackLight); textColor = array.getColor(R.styleable.BlackLight_CardForeground, 0); array.recycle(); } catch (NotFoundException e) { return; } for (int i = 0; i < tabhost.getTabWidget().getChildCount(); i++) { TextView tv = (TextView) tabhost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); tv.setTextColor(textColor); } } }
From source file:ru.gkpromtech.exhibition.organizations.OrganizationPlaceActivity.java
private View createIndicatorView(TabHost tabHost, String text) { View tabIndicator = getLayoutInflater().inflate(R.layout.layout_tab_passive_indicator, tabHost.getTabWidget(), false); ((TextView) tabIndicator.findViewById(R.id.textView)).setText(text); return tabIndicator; }
From source file:com.mychild.view.Parent.CustomTabActivity.java
public void setUpTab() { final TabHost tabHost = (TabHost) findViewById(R.id.tabhost2); tabHost.setup();//www .ja v a2 s. c o m tabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider); class TabDef { public final String Indicator;//, Content; public TabDef(String Indicator, ListView lv) { this.Indicator = Indicator; //this.Content = Content; } /*TabDef*/ } ; /*TabDef*/ for (TabDef thisTab : new TabDef[] { new TabDef("Exams", examsListView), new TabDef("Results", examsListView) }) { // final TextView contentview = new TextView(this); // contentview.setText(thisTab.Content); View indicatorview = android.view.LayoutInflater.from(this).inflate(R.layout.tabs_bg_plain, null); TextView tabTitle = (TextView) indicatorview.findViewById(R.id.tabsText); tabTitle.setText(thisTab.Indicator); tabHost.addTab(tabHost.newTabSpec(thisTab.Indicator).setIndicator(indicatorview) .setContent(new TabHost.TabContentFactory() { public View createTabContent(String tag) { Log.i("Tagggggg:", tag); if (tag == "Exams") { return examsListView; } else { return examsListView; } } /*createTabContent*/ }));/*TabContentFactory*/ } /*for*/ }
From source file:ru.gkpromtech.exhibition.events.EventsActivity.java
private View createIndicatorView(TabHost tabHost, String text, int resId) { View tabIndicator = LayoutInflater.from(this).inflate(R.layout.layout_image_tab_indicator, tabHost.getTabWidget(), // tab widget is the parent false); // no inflate params final TextView textView = (TextView) tabIndicator.findViewById(R.id.textView); final ImageView imageView = (ImageView) tabIndicator.findViewById(R.id.imageView); textView.setText(text);//w w w.j a v a 2 s . co m imageView.setImageDrawable(getResources().getDrawable(resId)); return tabIndicator; }
From source file:org.geometerplus.android.fbreader.QuotesFragmentActivity.java
public void setTabColor(TabHost tabhost) { for (int i = 0; i < tabhost.getTabWidget().getChildCount(); i++) tabhost.getTabWidget().getChildAt(i).setBackgroundColor(Color.CYAN); //unselected if (tabhost.getCurrentTab() == 0) tabhost.getTabWidget().getChildAt(tabhost.getCurrentTab()).setBackgroundColor(Color.RED); //1st tab selected else/* w w w.j a v a 2 s. c o m*/ tabhost.getTabWidget().getChildAt(tabhost.getCurrentTab()).setBackgroundColor(Color.BLUE); //2nd tab selected }
From source file:fr.vassela.acrrd.Main.java
@Override protected void onCreate(Bundle savedInstanceState) { try {/*from w w w . j av a2s . c om*/ localizerManager.setPreferencesLocale(getApplicationContext()); themeManager.setPreferencesTheme(getApplicationContext(), this); delegate = AppCompatDelegate.create(this, this); delegate.installViewFactory(); super.onCreate(savedInstanceState); delegate.onCreate(savedInstanceState); delegate.setContentView(R.layout.main); SharedPreferences sharedPreferences = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); int currentLocaleIndex = Integer.parseInt(sharedPreferences.getString("preferences_locale_set", "0")); String currentLocale = localizerManager.getLocale(getApplicationContext()).toString(); ArrayList<String> slideMenuTitles = new ArrayList<String>(); slideMenuTitles.add(getApplicationContext().getString(R.string.preferences_locale).toString()); //slideMenuTitles.add(getApplicationContext().getString(R.string.main_toolbar_test).toString()); slideMenuTitles.add(getApplicationContext().getString(R.string.main_toolbar_preferences).toString()); slideMenuTitles.add(getApplicationContext().getString(R.string.main_toolbar_log).toString()); slideMenuTitles.add(getApplicationContext().getString(R.string.main_toolbar_about).toString()); slideMenuTitles.add(getApplicationContext().getString(R.string.main_toolbar_exit).toString()); ArrayList<String> slideMenuSubtitles = new ArrayList<String>(); slideMenuSubtitles.add(currentLocale); //slideMenuSubtitles.add(getApplicationContext().getString(R.string.main_toolbar_test_description).toString()); slideMenuSubtitles.add( getApplicationContext().getString(R.string.main_toolbar_preferences_description).toString()); slideMenuSubtitles .add(getApplicationContext().getString(R.string.main_toolbar_log_description).toString()); slideMenuSubtitles .add(getApplicationContext().getString(R.string.main_toolbar_about_description).toString()); slideMenuSubtitles .add(getApplicationContext().getString(R.string.main_toolbar_exit_description).toString()); ArrayList<Integer> slideMenuIcons = new ArrayList<Integer>(); slideMenuIcons.add(themeManager.getLocaleFlag(getApplicationContext(), currentLocaleIndex)); slideMenuIcons.add(R.drawable.ic_menu_preferences); //slideMenuIcons.add(R.drawable.ic_menu_preferences); slideMenuIcons.add(R.drawable.ic_menu_archive); slideMenuIcons.add(R.drawable.ic_menu_info_details); slideMenuIcons.add(R.drawable.ic_menu_revert); drawerList = (ListView) findViewById(R.id.drawer_list); drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); SlidingMenuAdapter slidingMenuAdapter = new SlidingMenuAdapter(this, slideMenuTitles, slideMenuSubtitles, slideMenuIcons); drawerList.setAdapter(slidingMenuAdapter); drawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: break; /*case 0 : drawerLayout.closeDrawers(); startActivity(new Intent(getApplicationContext(), Test.class)); break;*/ case 1: drawerLayout.closeDrawers(); startActivity(new Intent(getApplicationContext(), Preferences.class)); break; case 2: drawerLayout.closeDrawers(); startActivity(new Intent(getApplicationContext(), TelephoneCallLogger.class)); break; case 3: drawerLayout.closeDrawers(); startActivity(new Intent(getApplicationContext(), About.class)); break; case 4: drawerLayout.closeDrawers(); RecordServiceManager recordServiceManager = new RecordServiceManager(); boolean isRecordServiceRunning = recordServiceManager.isRunning(getApplicationContext()); if (isRecordServiceRunning == false) { MonitoringServiceManager monitoringServiceManager = new MonitoringServiceManager(); monitoringServiceManager.stopService(getApplicationContext()); PurgeServiceManager purgeServiceManager = new PurgeServiceManager(); purgeServiceManager.stopService(getApplicationContext()); } moveTaskToBack(true); onBackPressed(); break; } } }); toolbar = (Toolbar) findViewById(R.id.main_toolbar); delegate.setSupportActionBar(toolbar); delegate.setTitle(getString(R.string.main_toolbar)); delegate.getSupportActionBar().setDisplayHomeAsUpEnabled(true); delegate.getSupportActionBar().setDisplayShowHomeEnabled(true); delegate.getSupportActionBar().setHomeButtonEnabled(true); TabHost tabhost = (TabHost) findViewById(android.R.id.tabhost); TabWidget tabwidget = tabhost.getTabWidget(); TabSpec tab_home = tabhost.newTabSpec(getString(R.string.main_tab_home)); TabSpec tab_records = tabhost.newTabSpec(getString(R.string.main_tab_records)); TabSpec tab_preferences = tabhost.newTabSpec(getString(R.string.main_tab_preferences)); TabSpec tab_about = tabhost.newTabSpec(getString(R.string.main_tab_about)); TabSpec tab_test = tabhost.newTabSpec("test"); tab_home.setIndicator(getString(R.string.main_tab_home), this.getResources().getDrawable(R.drawable.ic_menu_home)); tab_home.setContent(new Intent(this, Home.class)); tab_records.setIndicator(getString(R.string.main_tab_records), this.getResources().getDrawable(R.drawable.ic_voice_search)); tab_records.setContent(new Intent(this, Records.class)); tab_preferences.setIndicator(getString(R.string.main_tab_preferences), this.getResources().getDrawable(R.drawable.ic_menu_preferences)); tab_preferences.setContent(new Intent(this, Preferences.class)); tab_about.setIndicator(getString(R.string.main_tab_about), this.getResources().getDrawable(R.drawable.ic_menu_info_details)); tab_about.setContent(new Intent(this, About.class)); tab_test.setIndicator("test", this.getResources().getDrawable(R.drawable.ic_menu_preferences)); tab_test.setContent(new Intent(this, Test.class)); tabhost.addTab(tab_home); tabhost.addTab(tab_records); Intent intent = getIntent(); /*String setCurrentTab; if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if(extras == null) { setCurrentTab = null; } else { setCurrentTab = extras.getString("setCurrentTab"); } } else { setCurrentTab = (String) savedInstanceState.getSerializable("setCurrentTab"); } getIntent().removeExtra("setCurrentTab"); if(setCurrentTab.equals("home")) { tabhost.setCurrentTab(0); } else if(setCurrentTab.equals("records")) { tabhost.setCurrentTab(1); } else { tabhost.setCurrentTab(0); }*/ if (SHOW_RECORDS.equals(intent.getAction())) { tabhost.setCurrentTab(1); } else { tabhost.setCurrentTab(0); } initDrawer(); themeManager.setTabWidget(getApplicationContext(), tabwidget); } catch (Exception e) { Log.e("Main", "onCreate : " + getApplicationContext().getString(R.string.log_main_error_create) + " : " + e); databaseManager.insertLog(getApplicationContext(), "" + getApplicationContext().getString(R.string.log_main_error_create), new Date().getTime(), 1, false); } }
From source file:org.smap.smapTask.android.activities.MainTabsActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // must be at the beginning of any activity that can be called from an external intent try {/* ww w .java 2 s .com*/ Collect.createODKDirs(); } catch (RuntimeException e) { createErrorDialog(e.getMessage(), true); return; } setContentView(R.layout.main_tabs); Resources res = getResources(); // Resource object to get Drawables TabHost tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; Intent intent; tabHost.setBackgroundColor(Color.WHITE); tabHost.getTabWidget().setBackgroundColor(Color.DKGRAY); // Initialise a TabSpec and intent for each tab and add it to the TabHost intent = new Intent().setClass(this, MainListActivity.class); spec = tabHost.newTabSpec("taskList").setIndicator(getString(R.string.smap_taskList)).setContent(intent); tabHost.addTab(spec); /* * Initialise a Map tab */ Log.i("trial", "Creating Maps Activity"); intent = new Intent().setClass(this, MapsActivity.class); spec = tabHost.newTabSpec("taskMap").setIndicator(getString(R.string.smap_taskMap)).setContent(intent); tabHost.addTab(spec); // hack to set font size LinearLayout ll = (LinearLayout) tabHost.getChildAt(0); TabWidget tw = (TabWidget) ll.getChildAt(0); int fontsize = Collect.getQuestionFontsize(); ViewGroup rllf = (ViewGroup) tw.getChildAt(0); mTVFF = getTextViewChild(rllf); if (mTVFF != null) { mTVFF.setTextSize(fontsize); mTVFF.setTextColor(Color.WHITE); mTVFF.setPadding(0, 0, 0, 6); } ViewGroup rlrf = (ViewGroup) tw.getChildAt(1); mTVDF = getTextViewChild(rlrf); if (mTVDF != null) { mTVDF.setTextSize(fontsize); mTVDF.setTextColor(Color.WHITE); mTVDF.setPadding(0, 0, 0, 6); } }