I am making a game in android studio and I ran into a problem when designing the settings tab:
I have a settings XML file that I access through the java code from the main menu screen, and I want to set the checkboxes according to a sharedpreferences file.
The thing is that while the actual preferences are updated, whenever I call setChecked()
it doesn't do anything.
what I am trying to is:
final LayoutInflater factory = LayoutInflater.from(this);
final View settingsView = factory.inflate(R.layout.activity_settings, null);
CheckBox test = settingsView.findViewById(R.id.testCheck);
test.setChecked(true); // not really doing anything
Ty for all the help :)
Try like below.
setContentView(R.layout.activity_settings);
CheckBox test = settingsView.findViewById(R.id.testCheck);
test.post(new Runnable() {
@override
public void run() {
test.setChecked(true);
}});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.