Cistoran Cistoran - 2 months ago 8
Android Question

Handling Multiple "Screens" In Android via TableLayouts

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(;
TableLayout optionTable = (TableLayout)findViewById(;


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()) {
Button optbtn = (Button)findViewById(;


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