I’m trying to make an Options “Menu” Screen. When the menu button is pressed the menu comes up with a “button” that says Options when that is clicked, the function clicks a button called optionsButton. When that button is pressed I want one TableLayout to become Invisible and one to become visible.
Here is the code I have to hide the layouts.
public void optionButton(View view)
{
TableLayout mainTable = (TableLayout)findViewById(R.id.tableMain);
TableLayout optionTable = (TableLayout)findViewById(R.id.tableOptions);
mainTable.setVisibility(TableLayout.INVISIBLE);
optionTable.setVisibility(TableLayout.VISIBLE);
}
And here is the XML that handles my optionButton <Button android:onClick="optionButton" android:id="@+id/optionsButton" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Button" android:visibility="invisible"></Button>
And here is the code that handles my “Menu Button”
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.options:
Button optbtn = (Button)findViewById(R.id.optionsButton);
optbtn.performClick();
break;
default:
break;
}
return true;
}
The problem is that when the menu button is clicked, nothing happens. Any help on this issue would be greatly appreciated.
I fixed the problem by deleting the optionsTable and all of it’s contents. Remaking it and putting it below the mainTable in the Graphical Editor of main.xml