I have an Activity that uses a ViewSwitcher to switch between two views. The onCreate() method uses setContentview() to set the view to one of the two views.
When leaving the Activity and going back to it again later, I want the view that was shown last to be the one that is picked in the viewSwitcher (not the one in SetContentview every single time).
How would I accomplish this?
I tried something like this, but the app crashes when I try to load the Activity:
private View lastState = findViewById(R.id.activity_login_page);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(lastState);
I achieved something similar by using ViewFlipper.
SettingsActivity
ViewFlippingActivity
viewflipping_activity.xml
Sorry for the bad Explanation and difficult to read code im in a hurry. Hope it still provides some sort of help.