I think I get what you're trying to do now. In that case, I think you'd want something like this:
class MyClass implements OnMenuItemClickListener {
{
exit_app = menu.getItem(7);
text_enter = menu.getItem(1);
exit_app.setOnMenuItemClickListener(this);
text_enter.setOnMenuItemClickListener(this);
}
public boolean onMenuItemClick(MenuItem clickedItem)
{
switch (clickedItem.getId()) {
case R.id.exit_app:
try{
_run = false;
finish();
}catch(Exception c)
{
c.toString();
}
return true;
case R.id.text_enter:
_run = false;
try{
Thread.sleep(1000);
setContentView(R.layout.text_enter);
buttonCancel.setOnClickListener(buttonSendOnClickListener);
}catch(Exception x)
{
x.toString();
}
return true;
}
}
}
But a few more things: the numbers used in
menu.GetItem
should be made into constants, for example:
static final int EXIT_APP_MENU_INDEX = 7;
Also, the function with the switch won't compile as-is, it will need to return a value either after the switch or in a default case.