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.climprpiano.midisheetmusic.ChooseSongActivity.java

@Override
public void onCreate(Bundle state) {
    globalActivity = this;
    super.onCreate(state);

    Bitmap allFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.allfilesicon);
    Bitmap recentFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.recentfilesicon);
    Bitmap browseFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.browsefilesicon);

    final TabHost tabHost = getTabHost();

    tabHost.addTab(tabHost.newTabSpec("All").setIndicator("All", new BitmapDrawable(allFilesIcon))
            .setContent(new Intent(this, AllSongsActivity.class)));

    tabHost.addTab(tabHost.newTabSpec("Recent").setIndicator("Recent", new BitmapDrawable(recentFilesIcon))
            .setContent(new Intent(this, RecentSongsActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

    tabHost.addTab(tabHost.newTabSpec("Browse").setIndicator("Browse", new BitmapDrawable(browseFilesIcon))
            .setContent(new Intent(this, FileBrowserActivity.class)));

    tabHost.setCurrentTab(1);/*w w w .jav  a2 s  .co  m*/
}

From source file:com.midisheetmusic.ChooseSongActivity.java

@Override
public void onCreate(Bundle state) {
    globalActivity = this;
    super.onCreate(state);

    Bitmap allFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.allfilesicon);
    Bitmap recentFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.recentfilesicon);
    Bitmap browseFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.browsefilesicon);

    final TabHost tabHost = getTabHost();

    tabHost.addTab(tabHost.newTabSpec("All").setIndicator("All", new BitmapDrawable(allFilesIcon))
            .setContent(new Intent(this, AllSongsActivity.class)));

    tabHost.addTab(tabHost.newTabSpec("Recent").setIndicator("Recent", new BitmapDrawable(recentFilesIcon))
            .setContent(new Intent(this, RecentSongsActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

    tabHost.addTab(tabHost.newTabSpec("Browse").setIndicator("Browse", new BitmapDrawable(browseFilesIcon))
            .setContent(new Intent(this, FileBrowserActivity.class)));

}

From source file:org.agilespain.kitaos.TalksActivity.java

private TabHost.TabSpec createTabSpec(TabHost tabHost, String tag, int labelId) {
    final Context context = tabHost.getContext();

    final TabHost.TabSpec tabSpec = tabHost.newTabSpec(tag);

    final CharSequence label = context.getText(labelId);

    AttributeSet attrs = null;//from w  ww.  jav a2s . c o  m
    int defStyle = R.attr.kitaosTabViewStyle;
    final TextView view = new TextView(context, attrs, defStyle);
    view.setText(label);

    tabSpec.setIndicator(view);

    return tabSpec;
}

From source file:net.yolosec.upckeygen.ui.AboutTabHostActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.about_dialog);

    try {//from   w  ww  . j a  v a  2  s.  c  om
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    } catch (Exception e) {
        Log.e(TAG, "Exception", e);
    }

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

    TabHost.TabSpec tspec1 = tabs.newTabSpec("about");
    tspec1.setIndicator(getString(R.string.pref_2section));
    tspec1.setContent(R.id.text_about_scroll);
    TextView text = ((TextView) findViewById(R.id.text_about));
    text.setMovementMethod(LinkMovementMethod.getInstance());
    try {
        PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        String version = pInfo.versionName;
        text.append(version);
    } catch (Exception e) {
        Log.e(TAG, "Exception in getting app version", e);
    }
    tabs.addTab(tspec1);

    TabHost.TabSpec tspec2 = tabs.newTabSpec("credits");
    tspec2.setIndicator(getString(R.string.dialog_about_credits));
    tspec2.setContent(R.id.about_credits_scroll);
    ((TextView) findViewById(R.id.about_credits)).setMovementMethod(LinkMovementMethod.getInstance());
    tabs.addTab(tspec2);
    TabHost.TabSpec tspec3 = tabs.newTabSpec("license");
    tspec3.setIndicator(getString(R.string.dialog_about_license));
    tspec3.setContent(R.id.about_license_scroll);
    ((TextView) findViewById(R.id.about_license)).setMovementMethod(LinkMovementMethod.getInstance());
    tabs.addTab(tspec3);
}

From source file:com.divergentthoughtsgames.colonies.HowToPlayActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_how_to_play);

    // Parts adapted from 
    // https://github.com/commonsguy/cw-android/blob/master/Fancy/Tab/src/com/commonsware/android/fancy/TabDemo.java
    TabHost tabs = (TabHost) findViewById(R.id.tabhost);
    tabs.setup();/*  ww  w. j av  a2s .c o m*/

    TabHost.TabSpec spec = tabs.newTabSpec("Overview");
    spec.setContent(R.id.tab1);
    spec.setIndicator("Overview");
    tabs.addTab(spec);

    spec = tabs.newTabSpec("New Colony");
    spec.setContent(R.id.tab2);
    spec.setIndicator("New Colony");
    tabs.addTab(spec);

    spec = tabs.newTabSpec("Goals");
    spec.setContent(R.id.tab3);
    spec.setIndicator("Goals");
    tabs.addTab(spec);
}

From source file:com.midisheetmusicmemo.ChooseSongActivity.java

@Override
public void onCreate(Bundle state) {
    globalActivity = this;
    TommyConfig.init(this);
    super.onCreate(state);

    Bitmap allFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.allfilesicon);
    Bitmap recentFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.recentfilesicon);
    Bitmap browseFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.browsefilesicon);

    final TabHost tabHost = getTabHost();

    tabHost.addTab(tabHost.newTabSpec("All").setIndicator("All", new BitmapDrawable(allFilesIcon))
            .setContent(new Intent(this, AllSongsActivity.class)));

    tabHost.addTab(tabHost.newTabSpec("Recent").setIndicator("Recent", new BitmapDrawable(recentFilesIcon))
            .setContent(new Intent(this, RecentSongsActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

    tabHost.addTab(tabHost.newTabSpec("Browse").setIndicator("Browse", new BitmapDrawable(browseFilesIcon))
            .setContent(new Intent(this, FileBrowserActivity.class)));

}

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  a2 s  . com
    tab.setContent(new TabHost.TabContentFactory() {
        @Override
        public View createTabContent(String tag) {
            return view;
        }
    });
    tabhost.addTab(tab);
}

From source file:com.infine.android.devoxx.ui.MapHotelFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_map_detail, null);

    final Intent intent = BaseActivity.fragmentArgumentsToIntent(getArguments());
    Bundle extras = intent.getExtras();//ww  w  . ja  va 2  s .c o  m
    if (extras != null) {
        startTab = extras.getInt(EXTRA_ROOM);
    }
    TabHost tabHost = (TabHost) mRootView.findViewById(android.R.id.tabhost);
    tabHost.setup();
    tabHost.addTab(tabHost.newTabSpec(TAG_LEVEL_0).setIndicator(buildIndicator(R.string.tab_map_0))
            .setContent(R.id.tab_map_level0));
    tabHost.addTab(tabHost.newTabSpec(TAG_LEVEL_1).setIndicator(buildIndicator(R.string.tab_map_1))
            .setContent(R.id.tab_map_level1));
    tabHost.setCurrentTab(startTab);

    return mRootView;
}

From source file:com.ecml.ChooseSongActivity.java

@Override
public void onCreate(Bundle state) {

    globalActivity = this;
    super.onCreate(state);

    // Set the Action Bar Title of the Activity (corresponding to the first Tab)
    setTitle("ECML: Choose Song");

    Bitmap allFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.allfilesicon);
    Bitmap recentFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.recentfilesicon);
    Bitmap browseFilesIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.browsefilesicon);

    final TabHost tabHost = getTabHost();

    tabHost.addTab(tabHost.newTabSpec("All").setIndicator("All", new BitmapDrawable(allFilesIcon))
            .setContent(new Intent(this, AllSongsActivity.class)));

    tabHost.addTab(tabHost.newTabSpec("Recent").setIndicator("Recent", new BitmapDrawable(recentFilesIcon))
            .setContent(new Intent(this, RecentSongsActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

    tabHost.addTab(tabHost.newTabSpec("Browse").setIndicator("Browse", new BitmapDrawable(browseFilesIcon))
            .setContent(new Intent(this, FileBrowserActivity.class)));

    tabHost.setOnTabChangedListener(this);
}

From source file:org.n52.geoar.data.sos.SOSFeatureVisualization.java

@Override
public View getFeatureView(SpatialEntity2<? extends Geometry> entity, View convertView, ViewGroup parentView,
        Context activityContext) {
    ViewHolder viewHolder;// www.  jav  a2 s  . c om

    if (convertView == null) {
        convertView = LayoutInflater.from(activityContext).inflate(R.layout.sos_featureview, null);
        viewHolder = new ViewHolder();

        viewHolder.textViewServiceSensorId = (TextView) convertView.findViewById(R.id.textViewServiceSensorId);
        viewHolder.textViewDescription = (TextView) convertView.findViewById(R.id.textViewDescription);
        viewHolder.textViewName = (TextView) convertView.findViewById(R.id.textViewName);

        viewHolder.sosObservationView = (SOSObservationView) convertView.findViewById(R.id.sosObservationView);
        viewHolder.sosObservationView.setCapabilitiesCallable(viewHolder.capabilitiesCallable);
        viewHolder.sosObservationView.setObservationCallable(viewHolder.observationCallable);
        viewHolder.sosObservationView.setActivityContext(activityContext);

        TabHost tabHost = (TabHost) convertView.findViewById(android.R.id.tabhost);
        tabHost.setup();
        tabHost.addTab(tabHost.newTabSpec("FOI").setIndicator("Feature").setContent(R.id.scrollViewFOI));
        tabHost.addTab(tabHost.newTabSpec("SOS").setIndicator("Observations").setContent(R.id.layoutSOS));

        tabHost.setCurrentTab(0);

        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }

    if (entity instanceof FOI) {
        viewHolder.featureOfInterest = (FOI) entity;
        viewHolder.textViewName.setText(viewHolder.featureOfInterest.name);
        if (viewHolder.featureOfInterest.description != null) {
            viewHolder.textViewDescription.setText(Html.fromHtml(viewHolder.featureOfInterest.description));
        }
        viewHolder.textViewServiceSensorId.setText(viewHolder.featureOfInterest.id);
    }
    return convertView;
}