Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to let TabHost show in every Activity?
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/13623350/start-activity-from-an-other-activity-with-tabs">start Activity from an other Activity with Tabs</a> </p> </blockquote> <p><img src="https://i.stack.imgur.com/5YeIT.png" alt="enter image description here"><img src="https://i.stack.imgur.com/4izjK.png" alt="enter image description here"></p> <p>see the following two pictures, i want to click the icon "all songs" and then jump to a playlist. but i do not know how to use TabHost and display on the playlist? How to let TabHost show in every Activity?</p> <p>the code of Activity has TabHost:</p> <pre><code>/*package com.lxy.musicplayer.view; import com.lxy.musicplayer.R; import android.app.TabActivity; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Window; import android.widget.TabHost; public class BuddleTabHostActivity extends TabActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TabHost tab = getTabHost(); // LayoutInflater.from(this).inflate(R.layout.tabhost_layout, tab.getTabContentView(),true); super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.tabhost_layout); addIntentActivity(tab, MainActivity.class, "all songs"); addIntentActivity(tab, MainActivity.class, "Network songs "); addIntentActivity(tab, MainActivity.class, "my set"); tab.setCurrentTab(0); } private void addIntentActivity(TabHost tab,Class c,String title){ Intent intent = new Intent(); intent.setClass(this, c); TabHost.TabSpec spec = tab.newTabSpec(title); spec.setIndicator(title); spec.setContent(intent); tab.addTab(spec); } } */ package com.lxy.musicplayer.view; import com.lxy.musicplayer.R; import android.app.TabActivity; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.view.Window; import android.widget.TabHost; public class BuddleTabHostActivity extends TabActivity{ @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.tabhost_layout); //get switching object TabHost tab=getTabHost(); addIntentActivity(tab, MainActivity.class,"local"); addIntentActivity(tab, PlayActivity.class,"favorite"); addIntentActivity(tab, PlayListActivity.class,"online"); addIntentActivity(tab, MainActivity.class,"setting"); //executive tab default tab.setCurrentTab(0); } public void addIntentActivity(TabHost tab,Class&lt;?&gt; c,String str){ Intent intent=new Intent(); intent.setClass(this, c); //switching object and obtain tab TabHost.TabSpec spec=tab.newTabSpec(str); //set tab information //turn to the page display spec.setIndicator(str); spec.setContent(intent); //add tabs tab.addTab(spec); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload