解决方案 »
- 急急急,求大神指点,感激不尽
- 接收不到服务器返回的数据
- android源码packages/apps下的程序如何调试
- 做一Android 应用程序,各位进来瞧一瞧看一看
- Android手机如何查看最后一次关机时间?或者上次关机之前运行时间?
- 自定义View 全屏显示的问题
- 手机移动端开发问题sencha touch 和phonegap结合实现语音记录如何实现问题
- ActivityGroup在程序的运行当中重新Oncreate了一次
- Android播放rtsp实时视频延时
- 使用introspy追踪安卓app
- 请教Service中怎么判断当前Activity是否全屏?
- android中给Dialog设置的动画如何自定义修改参数
Stirng a = sp.getString("你存的值", null);
private CheckBox cb_protected;sp = getSharedPreferences("config", Context.MODE_PRIVATE);
boolean isProtecting = sp.getBoolean("isProtected", false);//每次进来的时候读取保存的数据
if (isProtecting) {
cb_protected.setText("已经开启了保护");
cb_protected.setChecked(true);
}
cb_protected.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if (isChecked) {
cb_protected.setText("已经开启保护");
Editor editor = sp.edit();
editor.putBoolean("isProtected", true);
editor.commit();//提交数据保存
} else {
cb_protected.setText("没有开启保护");
Editor editor = sp.edit();
editor.putBoolean("isProtected", false);
editor.commit();//提交数据保存
}
}
});