I think the most simple approach would be to let the Activity determine the state in onCreate() and create the valid Buttons accordingly (sounds like that is just about what you are doing).
Now, instead of manipulating the existing view (which can be a pain as complexity grows) simply restart the Activity, recreating the game with the same code as before.
// Move to new state
startActivity(new Intent(MainActivity.this, MainActivity.class));
This could cause some problems if the user would press the back button, although moving back would still show a correct state, it would be confusing behaviour. Atleast that is my opinion. To prevent this:
@Override
public void onBackPressed() {
// confirm exit being a dialog, this just mocks the intent of the code
if (confirmExit()) {
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
}
}
Eyecandy: You can define the transition between your activites to make it look a bit cooler.
Example with left to right transition in onCreate() of your MainActivity:
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
And here is the /res/anim/slide_in_right.xml and anim.slide_out_left.xml:
/// in_right
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate
android:duration="200"
android:fromXDelta="100%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="0%" />
</set>
// out_left
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate
android:duration="200"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="-100%"
android:toYDelta="0%" />
</set>
There are of course many answers to this question. I though honestly think this is the easiest to program, read and maintain, that I can think of.
Fragments: This approach could later be improved with fragments. This would give the same improvement to your app as Ajax does to server-based website (That is the most fitting anology in my mind). This is however outside the scope of this post to digg into. Just wanted to mention it.
As a final note, then my suggestion to the solution will be very much less painful to migrate to fragment based in the future than fiddling around adding/removing views from the activity would be.