我给了你标签活动管理的例子//已经声明了标签活动使用的数量包 com.technosoft.Concina_Peru;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;
import com.technosoft.FirstTab.FirstTab;
import com.technosoft.FourthTab.FourthTab;
import com.technosoft.SecondTab.SecondTab;
import com.technosoft.ThirdTab.ThirdTab;
public class ConcinaPeruTabbar extends TabActivity {
public static Context tabContext;
public static TabHost tabHost;
Context con;
public static String var = "";
public static Concina_Database db;
private void setupTabHost() {
tabHost = (TabHost) findViewById(android.R.id.tabhost);
tabHost.setup();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.starttab);
tabContext = this;
con = this.getApplicationContext();
db = new Concina_Database(con);
setupTabHost();
setupTab(new TextView(this), "Inicio");
setupTab(new TextView(this), "Recetas");
setupTab(new TextView(this), "Favoritos");
setupTab(new TextView(this), "Mas");
}
private void setupTab(final View view, final String tag) {
View tabview = createTabView(tabHost.getContext(), tag);
if(tag.equals("Inicio")){
tabHost.addTab((tabHost.newTabSpec("Inicio")).setIndicator(
tabview).setContent(new Intent(this, FirstTab.class)));
}
if(tag.equals("Recetas")){
tabHost.addTab((tabHost.newTabSpec("Recetas")).setIndicator(
tabview).setContent(new Intent(this, SecondTab.class)));
}
if(tag.equals("Favoritos")){
tabHost.addTab((tabHost.newTabSpec("Favoritos")).setIndicator(
tabview).setContent(new Intent(this, ThirdTab.class)));
}
if(tag.equals("Mas")){
tabHost.addTab((tabHost.newTabSpec("Mas")).setIndicator(
tabview).setContent(new Intent(this, FourthTab.class)));
}
}
private static View createTabView(final Context context, final String text) {
View view = LayoutInflater.from(context)
.inflate(R.layout.tabs_bg, null);
TextView tv = (TextView) view.findViewById(R.id.tabsText);
ImageView iv = (ImageView) view.findViewById(R.id.imageView1);
if (text.equals("Inicio")) {
iv.setBackgroundResource(R.drawable.tab_bg_image);
}
if (text.equals("Recetas")) {
iv.setBackgroundResource(R.drawable.tab_bg_image1);
}
if (text.equals("Favoritos")) {
iv.setBackgroundResource(R.drawable.tab_bg_image2);
}
if (text.equals("Mas")) {
iv.setBackgroundResource(R.drawable.tab_bg_image3);
}
tv.setText(text);
return view;
}
}
//第一个选项卡活动在这里定义
public class FirstTab extends ActivityGroup{
public static FirstTab group_FirstTab;
private ArrayList<View> history = new ArrayList<View>();
ProgressDialog PD;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
group_FirstTab = this;
View view = getLocalActivityManager().startActivity("CitiesAct", new
Intent(FirstTab.this,Inicio.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
replaceView(view);
}
public void replaceView(View view) {
history.add(view);
setContentView(view);
}
public void RemoveView(){
history.clear();
}
public void back(){
if(history.size() > 1) {
history.remove(history.size()-1);
setContentView(history.get(history.size()-1));
}else{
finish();
}
}
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if(keyCode == KeyEvent.KEYCODE_BACK){
group_FirstTab.back();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
类似的有另一个选项卡活动..现在你想去意图一个选项卡到另一个选项卡活动到另一个选项卡活动下面的代码跟随
对于 ex 想要将 0 标签活动转到 1 标签活动,然后使用
tab activity Class tab_0{
ConcinaPeruTabbar.tabHost.setCurrentTab(1);
}
如果您想将一个选项卡活动转到 simaar 选项卡活动,请使用此视图视图 =
FirstTab.group_FirstTab.getLocalActivityManager().startActivity("CitiesAct", new Intent(Inicio.this,Platos.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP).putExtra("platos", "Entradas")).getDecorView();
FirstTab.group_FirstTab.replaceView(view);