I have an OptionMenu
inside my activity
but when I choose an option it shows nothing. I've found some tutorials but they show what I already do. What is wrong?
Thank you for the replies.
This is the code at the moment:
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;
}
}
Aaaw.
There is a typo.
Not
public boolean OnOptionsItemSelected(MenuItem item)
but
public boolean onOptionsItemSelected(MenuItem item)
The initial letter of the method name is a lower case.