Possible Duplicate:
start Activity from an other Activity with Tabs


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?
the code of Activity has TabHost:
/*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<?> 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);
}
}
Please write below code for that, it will solve your problem.
ActivityStack.java
TabActivity.java
FirstActivity.java
SecondActivity.java
ThirdActivity.java
Add Below XML files into your res/layout folder.
1) tab_screen.xml
2) main.xml
AndroidManifest.xml:-
And see below link for more information with complete example.
Multiple Android Activities in a TabActivity