2 telen0928 telen0928 于 2013.07.30 21:14 提问

出现了fatal exception :main 这是其中的一段代码,大家看看有什么问题

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("");
            }

        }  

    });  

1个回答

cj6585256
cj6585256   2013.07.31 10:22

看代码没看出什么问题,clean下或者重启eclipse试试

Csdn user default icon
上传中...
上传图片
插入图片