2015-04-20 183 views
0

我做了一個用戶表,它看起來像包括一個自定義名稱字段。我想輸入數據到parse.com中的custmom列,但我得到一個錯誤

現在,無論何時我嘗試將數據放入此字段中,我都會收到錯誤消息。

我使用的代碼是。

ParseUser user = new ParseUser(); 
       user.setUsername(Name); 
       user.setPassword(Password); 
       user.setEmail("[email protected]"); 


       user.put("Name","test"); 

       user.signUpInBackground(new SignUpCallback() { 
        @Override 
        public void done(ParseException e) { 
         if (e == null) { 
          // Show a simple Toast message upon successful registration 
          Toast.makeText(getApplicationContext(), 
            "Successfully Signed up, please log in.", 
            Toast.LENGTH_LONG).show(); 
         } else { 
          Toast.makeText(getApplicationContext(), 
            "Sign up Error", Toast.LENGTH_LONG) 
            .show(); 
         } 
        } 


       }); 

但我收到「註冊錯誤」消息顯示。並沒有更新表中。

+0

錯誤說的是什麼? – Rami

回答

1

下面的代碼已經在我的許多項目上工作過(所以我認爲我會粘貼,以防它的幫助)。你從哪裏得到'setusername'和'setpassword'?

public void register(final View v){ 
    if(mUsernameField.getText().length() == 0 || mPasswordField.getText().length() == 0) 
     return; 

    v.setEnabled(false); 
    ParseUser user = new ParseUser(); 
    user.setUsername(mUsernameField.getText().toString()); 
    user.setPassword(mPasswordField.getText().toString()); 
    //mErrorField.setText(""); 

    user.signUpInBackground(new SignUpCallback() { 
     @Override 
     public void done(ParseException e) { 
      if (e == null) { 
       Intent intent = new Intent(RegisterActivity.this, LoggedIn.class); 
       startActivity(intent); 
       finish(); 
      } else { 
       // Sign up didn't succeed. Look at the ParseException 
       // to figure out what went wrong 
       switch(e.getCode()){ 
        case ParseException.USERNAME_TAKEN: 
         mErrorField.setText("Sorry, this username has already been taken."); 
         break; 
        case ParseException.USERNAME_MISSING: 
         mErrorField.setText("Sorry, you must supply a username to register."); 
         break; 
        case ParseException.PASSWORD_MISSING: 
         mErrorField.setText("Sorry, you must supply a password to register."); 
         break; 
        default: 
         mErrorField.setText(e.getLocalizedMessage()); 
       } 
       v.setEnabled(true); 
      } 
     } 
    }); 
} 
相關問題