我有一个OptionMenu
内部activity
,但是当我选择一个选项时,它什么也没有显示。我找到了一些教程,但它们显示了我已经做过的事情。怎么了?感谢您的答复。
这是目前的代码:
public class Listino extends TabActivity
{
final Context context = this;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
deleteFile("Ordinazioni.txt");
setContentView(R.layout.show_listino);
TabHost tabHost = getTabHost();
//Primi
Intent intentPrimi = new Intent().setClass(this, Primi.class);
TabSpec tabSpecPrimi = tabHost
.newTabSpec("Primi")
.setIndicator("Primi")
.setContent(intentPrimi);
//Secondi
Intent intentSecondi = new Intent().setClass(this, Secondi.class);
TabSpec tabSpecSecondi = tabHost
.newTabSpec("Secondi")
.setIndicator("Secondi")
.setContent(intentSecondi);
// Dolci
Intent intentDolci = new Intent().setClass(this, Dolci.class);
TabSpec tabSpecDolci = tabHost
.newTabSpec("Dolci")
.setIndicator("Dolci")
.setContent(intentDolci);
// Pizze
Intent intentPizze = new Intent().setClass(this, Pizze.class);
TabSpec tabSpecPizze = tabHost
.newTabSpec("Pizze")
.setIndicator("Pizze")
.setContent(intentPizze);
// Bevande
Intent intentBevande = new Intent().setClass(this, Bevande.class);
TabSpec tabSpecBevande = tabHost
.newTabSpec("Bevande")
.setIndicator("Bevande")
.setContent(intentBevande);
// Contorni
Intent intentContorni = new Intent().setClass(this, Bevande.class);
TabSpec tabSpecContorni = tabHost
.newTabSpec("Contorni")
.setIndicator("Contorni")
.setContent(intentContorni);
tabHost.addTab(tabSpecPrimi);
tabHost.addTab(tabSpecSecondi);
tabHost.addTab(tabSpecPizze);
tabHost.addTab(tabSpecDolci);
tabHost.addTab(tabSpecBevande);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.opzioni_menu, menu);
return true;
}
public boolean OnOptionsItemSelected(MenuItem item)
{
Toast.makeText(context, item.getItemId(), Toast.LENGTH_SHORT).show();
switch (item.getItemId())
{
case R.id.fineordinazione:
Intent intent = new Intent(context, AggiungiProdotto.class);
startActivity(intent);
return true;
case R.id.modificaordinazione:
break;
}
return false;
}
}
啊。