List of usage examples for android.widget TabHost addTab
public void addTab(TabSpec tabSpec)
From source file:com.google.adsensequickstart.CustomReportConfigFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.custom_report_config, container, false); TabHost host = (TabHost) rootView.findViewById(R.id.tabhost); host.setup();//w w w.ja v a2 s . c o m TabSpec spec = host.newTabSpec("Dimensions"); spec.setContent(R.id.dimensions_tab); spec.setIndicator("Dimensions"); host.addTab(spec); spec = host.newTabSpec("Metrics"); spec.setContent(R.id.metrics_tab); spec.setIndicator("Metrics"); host.addTab(spec); spec = host.newTabSpec("Dates"); spec.setContent(R.id.dates_tab); spec.setIndicator("Dates"); host.addTab(spec); if (customReportConfigReadyController == null) { return rootView; } List<ReportingMetadataEntry> dimensions = customReportConfigReadyController.getDimensions(); List<ReportingMetadataEntry> metrics = customReportConfigReadyController.getMetrics(); checker = new DimensionsMetricsCompatChecker(metrics, dimensions); // Get a list of dimension IDs ArrayList<String> dimensionIds = new ArrayList<String>(); for (ReportingMetadataEntry dimension : dimensions) { dimensionIds.add(dimension.getId()); } // Get a list of metric IDs ArrayList<String> metricIds = new ArrayList<String>(); for (ReportingMetadataEntry metric : metrics) { metricIds.add(metric.getId()); } dimensionsUI = new ArrayList<UiReportingItem>(); for (String dimension : dimensionIds) { dimensionsUI.add(new UiReportingItem(dimension, false, true)); } dimensionAdapter = new DimensionMetricAdapter(getActivity(), R.layout.custom_report_list_item, dimensionsUI, false); ListView lvdimension = (ListView) rootView.findViewById(R.id.dimensions_list); lvdimension.setAdapter(dimensionAdapter); metricsUI = new ArrayList<UiReportingItem>(); for (String metric : metricIds) { metricsUI.add(new UiReportingItem(metric, false, true)); } metricAdapter = new DimensionMetricAdapter(getActivity(), R.layout.custom_report_list_item, metricsUI, true); ListView lvmetric = (ListView) rootView.findViewById(R.id.metrics_list); lvmetric.setAdapter(metricAdapter); dimensionAdapter.setChangeListener(this); metricAdapter.setChangeListener(this); rootView.findViewById(R.id.generate_bt).setOnClickListener(this); rootView.findViewById(R.id.from_bt).setOnClickListener(this); rootView.findViewById(R.id.to_bt).setOnClickListener(this); return rootView; }
From source file:com.esminis.server.library.dialog.about.AboutViewImpl.java
private void addTab(TabHost tabhost, Context context, @StringRes int title, final View view) { TabHost.TabSpec tab = tabhost.newTabSpec(context.getString(title)); tab.setIndicator(tab.getTag());//from w w w . j a v a 2s. c o m tab.setContent(new TabHost.TabContentFactory() { @Override public View createTabContent(String tag) { return view; } }); tabhost.addTab(tab); }
From source file:com.swiftnav.piksidroid.MainActivity.java
private void setupUI() { TabHost tabHost = (TabHost) findViewById(R.id.tabHost); tabHost.setup();/* w w w . j a v a2s .c o m*/ TabHost.TabSpec tabSpec = tabHost.newTabSpec("Piksi"); tabSpec.setContent(R.id.piksi); tabSpec.setIndicator("Piksi"); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("Tracking"); tabSpec.setContent(R.id.tracking); tabSpec.setIndicator("Tracking"); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("Map"); tabSpec.setContent(R.id.map); tabSpec.setIndicator("Map"); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("Observation"); tabSpec.setContent(R.id.observation); tabSpec.setIndicator("Observation"); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("RTK"); tabSpec.setContent(R.id.rtk); tabSpec.setIndicator("RTK"); tabHost.addTab(tabSpec); tabHost.setOnTabChangedListener(tabChanger); ((EditText) findViewById(R.id.console)).setText("Piksi not connected!"); ((EditText) findViewById(R.id.console)).setTextIsSelectable(false); findViewById(R.id.console).setClickable(false); findViewById(R.id.scrollView).setClickable(false); findViewById(R.id.scrollView).setFocusable(false); findViewById(R.id.scrollView).setOnTouchListener(null); findViewById(R.id.scrollView).setPressed(false); com.swiftnav.piksidroid.MapFragment mFrag = ((com.swiftnav.piksidroid.MapFragment) getFragmentManager() .findFragmentById(R.id.map_fragment)); com.google.android.gms.maps.MapFragment mGFrag = (com.google.android.gms.maps.MapFragment) mFrag .getChildFragmentManager().findFragmentById(R.id.gmap_fragment); mGFrag.getMapAsync(mFrag); View decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); }
From source file:com.miuidev.themebrowser.MainActivity.java
/** Called when the activity is first created. */ @Override/*from w w w. j a va 2s.c om*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tab); mHandler = new Handler(); checkUpdate.start(); TabHost tabHost = getTabHost(); TabHost.TabSpec spec; Intent intent; intent = new Intent().setClass(this, FeaturedThemesActivity.class); spec = tabHost.newTabSpec("featuredthemes").setIndicator(getString(R.string.tab_featured_themes)) .setContent(intent); tabHost.addTab(spec); intent = new Intent().setClass(this, AllThemesActivity.class); spec = tabHost.newTabSpec("allthemes").setIndicator(getString(R.string.tab_all_themes)).setContent(intent); tabHost.addTab(spec); }
From source file:fr.mixit.android.ui.SpeakerDetailActivity.java
/** Build and add "presentations" tab. */ private void setupPresentationsTab() { final TabHost host = getTabHost(); final Intent intent = new Intent(Intent.ACTION_VIEW, buildSessionsDirUri(mSpeakerId)); intent.addCategory(Intent.CATEGORY_TAB); // Sessions content comes from reused activity host.addTab(host.newTabSpec(TAG_PRESENTATIONS).setIndicator(buildIndicator(R.string.speaker_sessions)) .setContent(intent));// w ww .ja v a 2 s. c o m }
From source file:org.runnerup.view.MainLayout.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.main);//from w w w. j av a 2 s . c om int versionCode = 0; UpgradeState upgradeState = UpgradeState.UNKNOWN; SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); Editor editor = pref.edit(); try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); versionCode = pInfo.versionCode; int version = pref.getInt("app-version", -1); if (version == -1) { upgradeState = UpgradeState.NEW; } else if (versionCode == version) { upgradeState = UpgradeState.SAME; } else if (versionCode > version) { upgradeState = UpgradeState.UPGRADE; } else if (versionCode < version) { upgradeState = UpgradeState.DOWNGRADE; } } catch (NameNotFoundException e) { e.printStackTrace(); } editor.putInt("app-version", versionCode); boolean km = Formatter.getUseKilometers(getResources(), pref, editor); if (upgradeState == UpgradeState.NEW) { editor.putString(getResources().getString(R.string.pref_autolap), Double.toString(km ? Formatter.km_meters : Formatter.mi_meters)); } editor.commit(); // clear basicTargetType between application startup/shutdown pref.edit().remove(getString(R.string.pref_basic_target_type)).commit(); Log.e(getClass().getName(), "app-version: " + versionCode + ", upgradeState: " + upgradeState + ", km: " + km); // convert pref_mute to pref_mute_bool Resources res = getResources(); try { if (pref.contains(res.getString(R.string.pref_mute))) { String v = pref.getString(res.getString(R.string.pref_mute), "no"); editor.putBoolean(res.getString(R.string.pref_mute_bool), v.equalsIgnoreCase("yes")); editor.remove(res.getString(R.string.pref_mute)); editor.commit(); } } catch (Exception e) { } PreferenceManager.setDefaultValues(this, R.xml.settings, false); PreferenceManager.setDefaultValues(this, R.xml.audio_cue_settings, true); TabHost tabHost = getTabHost(); // The activity TabHost tabHost.addTab(tabHost.newTabSpec("Start") .setIndicator(getString(R.string.Start), myGetDrawable(R.drawable.ic_tab_main)) .setContent(new Intent(this, StartActivity.class))); tabHost.addTab(tabHost.newTabSpec("Feed") .setIndicator(getString(R.string.feed), myGetDrawable(R.drawable.ic_tab_feed)) .setContent(new Intent(this, FeedActivity.class))); tabHost.addTab(tabHost.newTabSpec("History") .setIndicator(getString(R.string.History), myGetDrawable(R.drawable.ic_tab_history)) .setContent(new Intent(this, HistoryActivity.class))); tabHost.addTab(tabHost.newTabSpec("Settings") .setIndicator(getString(R.string.Settings), myGetDrawable(R.drawable.ic_tab_setup)) .setContent(new Intent(this, SettingsActivity.class))); tabHost.setCurrentTab(0); WidgetUtil.addLegacyOverflowButton(getWindow()); if (upgradeState == UpgradeState.UPGRADE) { whatsNew(); } //GPS is essential, always nag user if not granted requestGpsPermissions(this, tabHost.getCurrentView()); //Import workouts/schemes. No permission needed handleBundled(getApplicationContext().getAssets(), "bundled", getFilesDir().getPath() + "/.."); // if we were called from an intent-filter because user opened "runnerup.db.export", load it final Uri data = getIntent().getData(); if (data != null) { if (SettingsActivity.requestReadStoragePermissions(MainLayout.this)) { String filePath = null; if ("content".equals(data.getScheme())) { Cursor cursor = this.getContentResolver().query(data, new String[] { android.provider.MediaStore.Images.ImageColumns.DATA }, null, null, null); cursor.moveToFirst(); filePath = cursor.getString(0); cursor.close(); } else { filePath = data.getPath(); } Log.i(getClass().getSimpleName(), "Importing database from " + filePath); DBHelper.importDatabase(MainLayout.this, filePath); } else { Toast.makeText(this, "Storage permission not granted in Android settings, db is not imported.", Toast.LENGTH_SHORT).show(); } } }
From source file:paarmann.physikprofil.MainActivity.java
private void initTabs() { TabHost tabHost = (TabHost) findViewById(R.id.tabHost); tabHost.setup();//from w ww . jav a2 s . c om TabHost.TabSpec tsHA = tabHost.newTabSpec("TAB_HA"); tsHA.setIndicator("Hausaufgaben"); tsHA.setContent(R.id.tabHA); tabHost.addTab(tsHA); TabHost.TabSpec tsDates = tabHost.newTabSpec("TAB_DATES"); tsDates.setIndicator("Termine"); tsDates.setContent(R.id.tabDates); tabHost.addTab(tsDates); }
From source file:fr.mixit.android.ui.StarredActivity.java
/** Build and add "speakers" tab. */ private void setupSpeakersTab() { final TabHost host = getTabHost(); final Intent intent = new Intent(Intent.ACTION_VIEW, MixItContract.Speakers.CONTENT_STARRED_URI); intent.addCategory(Intent.CATEGORY_TAB); // Speakers content comes from reused activity host.addTab(host.newTabSpec(TAG_SPEAKERS).setIndicator(buildIndicator(R.string.starred_speakers)) .setContent(intent));/* w ww . jav a2 s . c o m*/ }
From source file:com.vuze.android.remote.dialog.DialogFragmentFilterByTags.java
@NonNull @Override//from w w w . ja v a 2s. c om public Dialog onCreateDialog(Bundle savedInstanceState) { SessionInfo sessionInfo = getSessionInfo(); List<Map<?, ?>> tags = sessionInfo == null ? null : sessionInfo.getTags(); if (tags != null && tags.size() > 0) { TreeMap<String, Long> map = new TreeMap<>(); for (Object o : tags) { if (o instanceof Map) { Map<?, ?> mapTag = (Map<?, ?>) o; long uid = MapUtils.getMapLong(mapTag, "uid", 0); String name = MapUtils.getMapString(mapTag, "name", "??"); int type = MapUtils.getMapInt(mapTag, "type", 0); if (type == 3) { // type-name will be "Manual" :( name = "Tag: " + name; } else { String typeName = MapUtils.getMapString(mapTag, "type-name", null); if (typeName != null) { name = typeName + ": " + name; } } map.put(name, uid); } } long[] vals = new long[map.size()]; String[] strings = map.keySet().toArray(new String[map.keySet().size()]); for (int i = 0; i < vals.length; i++) { vals[i] = map.get(strings[i]); } filterByList = new ValueStringArray(vals, strings); } if (filterByList == null) { filterByList = AndroidUtils.getValueStringArray(getResources(), R.array.filterby_list); } AndroidUtils.AlertDialogBuilder alertDialogBuilder = AndroidUtils.createAlertDialogBuilder(getActivity(), R.layout.dialog_filter_by); View view = alertDialogBuilder.view; AlertDialog.Builder builder = alertDialogBuilder.builder; // get our tabHost from the xml TabHost tabHost = (TabHost) view.findViewById(R.id.filterby_tabhost); tabHost.setup(); // create tab 1 TabHost.TabSpec spec1 = tabHost.newTabSpec("tab1"); spec1.setIndicator("States"); spec1.setContent(R.id.filterby_sv_state); tabHost.addTab(spec1); //create tab2 TabHost.TabSpec spec2 = tabHost.newTabSpec("tab2"); spec2.setIndicator("Tags"); spec2.setContent(R.id.filterby_tv_tags); tabHost.addTab(spec2); int height = AndroidUtilsUI.dpToPx(32); tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = height; tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = height; TextView tvState = (TextView) view.findViewById(R.id.filterby_tv_state); tvState.setMovementMethod(LinkMovementMethod.getInstance()); final TextView tvTags = (TextView) view.findViewById(R.id.filterby_tv_tags); tvTags.setMovementMethod(LinkMovementMethod.getInstance()); // for API <= 10 (maybe 11?), otherwise tags will display on one line tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { if (!tabId.equals("tab2")) { return; } tvTags.post(new Runnable() { @Override public void run() { spanTags.updateTags(); } }); } }); builder.setTitle(R.string.filterby_title); // Add action buttons builder.setPositiveButton(R.string.action_filterby, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (mapSelectedTag == null) { return; } long uidSelected = MapUtils.getMapLong(mapSelectedTag, "uid", -1); String name = MapUtils.getMapString(mapSelectedTag, "name", "??"); mListener.filterBy(uidSelected, name, true); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { DialogFragmentFilterByTags.this.getDialog().cancel(); } }); List<Map<?, ?>> manualTags = new ArrayList<>(); List<Map<?, ?>> stateTags = new ArrayList<>(); if (sessionInfo != null) { // Dialog never gets called wehn getTags has no tags List<Map<?, ?>> allTags = sessionInfo.getTags(); if (allTags != null) { for (Map<?, ?> mapTag : allTags) { int type = MapUtils.getMapInt(mapTag, "type", 0); switch (type) { case 0: case 1: case 2: stateTags.add(mapTag); break; case 3: // manual manualTags.add(mapTag); break; } } } } SpanTagsListener l = new SpanTagsListener() { @Override public void tagClicked(Map mapTag, String name) { mapSelectedTag = mapTag; // todo: long click, don't exit long uidSelected = MapUtils.getMapLong(mapSelectedTag, "uid", -1); mListener.filterBy(uidSelected, name, true); DialogFragmentFilterByTags.this.getDialog().dismiss(); } @Override public int getTagState(Map mapTag, String name) { if (mapSelectedTag == null) { return SpanTags.TAG_STATE_UNSELECTED; } long uidSelected = MapUtils.getMapLong(mapSelectedTag, "uid", -1); if (uidSelected == -1) { return SpanTags.TAG_STATE_UNSELECTED; } long uidQuery = MapUtils.getMapLong(mapTag, "uid", -1); return uidQuery == uidSelected ? SpanTags.TAG_STATE_SELECTED : SpanTags.TAG_STATE_UNSELECTED; } }; spanTags = new SpanTags(getActivity(), sessionInfo, tvTags, l); spanTags.setTagMaps(manualTags); spanTags.setShowIcon(false); spanTags.updateTags(); SpanTags spanState = new SpanTags(getActivity(), sessionInfo, tvState, l); spanState.setTagMaps(stateTags); spanState.setShowIcon(false); spanState.updateTags(); return builder.create(); }
From source file:com.google.android.apps.iosched.ui.SessionDetailActivity.java
/** Build and add "summary" tab. */ private void setupSummaryTab() { final TabHost host = getTabHost(); // Summary content comes from existing layout host.addTab(host.newTabSpec(TAG_SUMMARY).setIndicator(buildIndicator(R.string.session_summary)) .setContent(R.id.tab_session_summary)); }