public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
loginBtn = (Button)findViewById(R.id.login_btn_login);
registerBtn = (Button)findViewById(R.id.login_btn_zhuce);
inputUsername = (EditText)findViewById(R.id.login_edit_account);
inputPassword = (EditText)findViewById(R.id.login_edit_pwd);
sp = getSharedPreferences("userdata",0);
//初始化数据
LoadUserdata();
//检查网络
CheckNetworkState();
//监听记住密码选项
saveInfoItem.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
// TODO Auto-generated method stub
//载入用户信息
Editor editor = sp.edit();
if(saveInfoItem.isChecked())
{
//获取已经存在的用户名和密码
String realUsername = sp.getString("username", "");
String realPassword = sp.getString("password", "");
editor.putBoolean("checkstatus", true);
editor.commit();
if((!realUsername.equals(""))&&!(realUsername==null)||(!realPassword.equals(""))||!(realPassword==null))
{
//清空输入框
inputUsername.setText("");
inputPassword.setText("");
//设置已有值
inputUsername.setText(realUsername);
inputPassword.setText(realPassword);
}
}else
{
editor.putBoolean("checkstatus", false);
editor.commit();
//清空输入框
inputUsername.setText("");
inputPassword.setText("");
}
}
});
看代码没看出什么问题,clean下或者重启eclipse试试