Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Actually i have 3 buttons.User should click on any one button then all the 3 buttons should disable permanently throughout the app(when we close and open the app, buttons should be in disable state).How can i achieve this?

Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
258 views
Welcome To Ask or Share your Answers For Others

1 Answer

define the behavior in SharePreferences:

for example use this in onResume:

SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
boolean enabled = pref.getBoolean("isEnabled",true);
myButton.setEnabled(enabled);

in onClick event of the button do this:

SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
pref.edit().putBoolean("isEnabled",false).commit();
myButton.setEnabled(false);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...