I have a class where I create three tabs Tab.
The code is as follows
public class Tab extends TabActivity{
public void onCreate (Bundle savedinstanceState){
super.onCreate(savedinstanceState);
setContentView(R.layout.tab);
Bundle bundle = getIntent().getExtras();
String idReunion = bundle.getString("idReunion");
String nombreProyecto = bundle.getString("nombre_proyecto");
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
Resources res = getResources();
intent = new Intent();
intent.putExtra("idReunion", idReunion);
intent.putExtra("nombre_proyecto",nombreProyecto);
intent.setClass(this, PestanaSinAsignar.class);
spec = tabHost.newTabSpec("Pestaña 1").setIndicator("Sin asignar").setContent(intent);
tabHost.addTab(spec);
intent.putExtra("idReunion", idReunion);
intent.putExtra("nombre_proyecto",nombreProyecto);
intent.setClass(this, PestanaAsignadas.class);
spec = tabHost.newTabSpec("Pestaña 2").setIndicator("Asignadas").setContent(intent);
tabHost.addTab(spec);
intent.putExtra("idReunion", idReunion);
intent.putExtra("nombre_proyecto",nombreProyecto);
intent.setClass(this, PestanaAsignadaOtros.class);
spec = tabHost.newTabSpec("Pestaña 3").setIndicator("AsignadasUsuarios").setContent(intent);
tabHost.addTab(spec);
}
}
The problem is that when I click in the tab two or three always executes code PestanaAsignadaOtros class which is the class associated with the tab three.
It would be logical that when you press the tab two run PestanaAsignadas class code and if I click the tab three run the class code AsignadaOtros Pestana.
Why always running PestanaAsignadaOtros code?
You need to create different intents for each tab, currently you are trying to use the same intent for three different purposes: