Example usage for android.widget TabHost newTabSpec

List of usage examples for android.widget TabHost newTabSpec

Introduction

In this page you can find the example usage for android.widget TabHost newTabSpec.

Prototype

@NonNull
public TabSpec newTabSpec(@NonNull String tag) 

Source Link

Document

Creates a new TabSpec associated with this tab host.

Usage

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 w  ww .  j  a  v  a  2s.  co  m*/
    host.addTab(spec);
}

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  av  a 2 s .c o m
    tabHost.addTab(tabSpec);
}

From source file:co.uk.alt236.restclient4android.activities.ActivityMain.java

private void addTab(TabHost tabHost, RequestTabsAdapter tabAdapter, String tabSpec, String title,
        Class<? extends RestRequestFragmentInterface> clss, Bundle args) {
    tabAdapter.addTab(tabHost.newTabSpec(tabSpec).setIndicator(title), clss, args);
}

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  w  w  w .ja v a  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: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();//  ww  w.ja va 2 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.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();/*from w  w  w  .j a va 2s  .co  m*/

    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);
                }
            });
}

From source file:com.google.sample.castcompanionlibrary.cast.tracks.ui.TracksChooserDialog.java

private void setupView(View view) {
    ListView listView1 = (ListView) view.findViewById(R.id.listview1);
    ListView listView2 = (ListView) view.findViewById(R.id.listview2);
    TextView textEmptyMessageView = (TextView) view.findViewById(R.id.text_empty_message);
    TextView audioEmptyMessageView = (TextView) view.findViewById(R.id.audio_empty_message);
    partitionTracks();//from www . j  a  v  a 2s . co  m

    mTextAdapter = new TracksListAdapter(getActivity(), R.layout.tracks_row_layout, mTextTracks,
            mSelectedTextPosition);
    mAudioVideoAdapter = new TracksListAdapter(getActivity(), R.layout.tracks_row_layout, mAudioTracks,
            mSelectedAudioPosition);

    listView1.setAdapter(mTextAdapter);
    listView2.setAdapter(mAudioVideoAdapter);

    TabHost tabs = (TabHost) view.findViewById(R.id.tabhost);
    tabs.setup();

    // create tab 1
    TabHost.TabSpec tab1 = tabs.newTabSpec("tab1");
    if (mTextTracks == null || mTextTracks.isEmpty()) {
        listView1.setVisibility(View.INVISIBLE);
        tab1.setContent(R.id.text_empty_message);
    } else {
        textEmptyMessageView.setVisibility(View.INVISIBLE);
        tab1.setContent(R.id.listview1);
    }
    tab1.setIndicator(getString(R.string.caption_subtitles));
    tabs.addTab(tab1);

    // create tab 2
    TabHost.TabSpec tab2 = tabs.newTabSpec("tab2");
    if (mAudioTracks == null || mAudioTracks.isEmpty()) {
        listView2.setVisibility(View.INVISIBLE);
        tab2.setContent(R.id.audio_empty_message);
    } else {
        audioEmptyMessageView.setVisibility(View.INVISIBLE);
        tab2.setContent(R.id.listview2);
    }
    tab2.setIndicator(getString(R.string.caption_audio));
    tabs.addTab(tab2);
}

From source file:com.google.android.libraries.cast.companionlibrary.cast.tracks.ui.TracksChooserDialog.java

private void setUpView(View view) {
    ListView listView1 = (ListView) view.findViewById(R.id.listview1);
    ListView listView2 = (ListView) view.findViewById(R.id.listview2);
    TextView textEmptyMessageView = (TextView) view.findViewById(R.id.text_empty_message);
    TextView audioEmptyMessageView = (TextView) view.findViewById(R.id.audio_empty_message);
    partitionTracks();/*from  w  w w. j a  va 2s.  c  o  m*/

    mTextAdapter = new TracksListAdapter(getActivity(), R.layout.tracks_row_layout, mTextTracks,
            mSelectedTextPosition);
    mAudioVideoAdapter = new TracksListAdapter(getActivity(), R.layout.tracks_row_layout, mAudioTracks,
            mSelectedAudioPosition);

    listView1.setAdapter(mTextAdapter);
    listView2.setAdapter(mAudioVideoAdapter);

    TabHost tabs = (TabHost) view.findViewById(R.id.tabhost);
    tabs.setup();

    // create tab 1
    TabHost.TabSpec tab1 = tabs.newTabSpec("tab1");
    if (mTextTracks == null || mTextTracks.isEmpty()) {
        listView1.setVisibility(View.INVISIBLE);
        tab1.setContent(R.id.text_empty_message);
    } else {
        textEmptyMessageView.setVisibility(View.INVISIBLE);
        tab1.setContent(R.id.listview1);
    }
    tab1.setIndicator(getString(R.string.ccl_caption_subtitles));
    tabs.addTab(tab1);

    // create tab 2
    TabHost.TabSpec tab2 = tabs.newTabSpec("tab2");
    if (mAudioTracks == null || mAudioTracks.isEmpty()) {
        listView2.setVisibility(View.INVISIBLE);
        tab2.setContent(R.id.audio_empty_message);
    } else {
        audioEmptyMessageView.setVisibility(View.INVISIBLE);
        tab2.setContent(R.id.listview2);
    }
    tab2.setIndicator(getString(R.string.ccl_caption_audio));
    tabs.addTab(tab2);
}

From source file:com.miuidev.themebrowser.MainActivity.java

/** Called when the activity is first created. */
@Override/*w  w  w. j  a  v  a 2  s  .  c o m*/
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:com.swiftnav.piksidroid.MainActivity.java

private void setupUI() {
    TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
    tabHost.setup();/*from   w  w  w.  jav a  2s  . com*/

    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);
}