开发者

CheckBox.setChecked() is not working

开发者 https://www.devze.com 2023-03-16 18:15 出处:网络
So, this is simply not working. CheckBox chck_bluetooth = (CheckBox) findViewById(R.id.chck_bluetooth);

So, this is simply not working.

CheckBox chck_bluetooth = (CheckBox) findViewById(R.id.chck_bluetooth);
if (mProperties.getProperty("bluetooth") == "true") {
    ch开发者_JAVA百科ck_bluetooth.setChecked(true);
    Log.i("Properties", "bluetooth = " + mProperties.getProperty("bluetooth"));
} else {
    chck_bluetooth.setChecked(false);
    Log.i("Properties", "bluetooth = " + mProperties.getProperty("bluetooth"));
}

Well, the log told me that bluetooth were set to "true", so I guess there must be a problem with the checkbox.


If the property value is a string, you need to use equals() to compare it:

if (mProperties.getProperty("bluetooth").equals("true")) {
0

精彩评论

暂无评论...
验证码 换一张
取 消