I have a program that implements several onClickListeners. So as the user progresses through the button clicks. Is there anyway to save which onClick listener the user was on before they left the application or is was destroyed?
Use sharedpreference to achieve this. store the button name and its value whenever you click on any button.
example
SharedPreferences pref = getSharedPreferences(PREFS_NAME,MODE_PRIVATE);
passwordInString = password.getText().toString();
userNameInString = username.getText().toString();
getSharedPreferences(PREFS_NAME, MODE_PRIVATE)
.edit()
.putString(PREFS_USERNAME, passwordInString)
.putString(PREFS_PASSWORD, userNameInString)
.commit();
and in oncreate() always get the state of button using the following code Sample example
String usernameName = pref.getString(PREFS_USERNAME, "");
String upassWord = pref.getString(PREFS_PASSWORD, "");
depending on the value you can set the state of button
You could use SharedPreferences for that purpose.
来源:https://stackoverflow.com/questions/6514994/how-to-save-state-of-onclicklistener