I'm a beginner in android, my question is the following. I knew the TabHost component and found it very interesting to implement it in the application. The app has a list with restaurants and the person chooses the restaurant it opens another acitivity with the menus according to the chosen restaurant, it is working however when I choose the restaurant it opens a new activity and Tabhost disappears. My question is the following how to open this new Activity inside the tabhost (tabspec)? Here is the code:
Creating tabs:
public class tabs extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_pedido);
// create the TabHost that will contain the Tabs
TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
tabHost.setup();
TabSpec tab1 = tabHost.newTabSpec("Aba 1");
tab1.setContent(new Intent(this, lista_restaurantes.class));
tab1.setIndicator("",
getResources().getDrawable(R.drawable.ic_restaurante));
TabSpec tab2 = tabHost.newTabSpec("Aba 2");
tab2.setIndicator("", getResources().getDrawable(R.drawable.ic_promo));
tab2.setContent(new Intent(this, promocoes.class));
TabSpec tab3 = tabHost.newTabSpec("Aba 3");
tab3.setIndicator("",
getResources().getDrawable(R.drawable.ic_carrrinho));
tab3.setContent(new Intent(this, carrinho.class));
/** Add the tabs to the TabHost to display. */
tabHost.addTab(tab1);
tabHost.addTab(tab2);
tabHost.addTab(tab3);
tabHost.setCurrentTab(0);
}
}
It loads the class lista_restaurante
into TabSpec
public class lista_restaurantes extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.lista_restaurantes);
// Hashmap for ListView
restauranteList = new ArrayList<HashMap<String, String>>();
// chama restaurante
new restaurante().execute()
// Cria lista com Vendas no Dia
ListView lv = getListView();
// Quando Selecionar um restaurante
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// OBTEM o valor da ID
String pid = ((TextView) view.findViewById(R.id.pid)).getText()
.toString();
Chama intent com o cardapio de acordo com restaurante
Intent intent = new
Intent(lista_restaurantes.this,lista_caradapio.class);
intent.putExtra(TAG_PID, pid);
Chama a acctivity lista_cardapio
startActivity(intent);
}
});
}
How to call lista_cardapio.class
within tabspec?