CheckBox.setChecked()不起作用



所以,这根本不起作用。

CheckBox chck_bluetooth = (CheckBox) findViewById(R.id.chck_bluetooth);
if (mProperties.getProperty("bluetooth") == "true") {
    chck_bluetooth.setChecked(true);
    Log.i("Properties", "bluetooth = " + mProperties.getProperty("bluetooth"));
} else {
    chck_bluetooth.setChecked(false);
    Log.i("Properties", "bluetooth = " + mProperties.getProperty("bluetooth"));
}

好吧,日志告诉我蓝牙设置为"true",所以我想复选框一定有问题。

如果属性值是字符串,则需要使用equals()进行比较:

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

最新更新