我想输入数据到parse.com中的custmom列,但我得到一个错误
我做了一个用户表,它看起来像包括一个自定义名称字段。我想输入数据到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();
}
}
});
但我收到“注册错误”消息显示。并没有更新表中。
回答:
下面的代码已经在我的许多项目上工作过(所以我认为我会粘贴,以防它的帮助)。你从哪里得到'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);
}
}
});
}
以上是 我想输入数据到parse.com中的custmom列,但我得到一个错误 的全部内容, 来源链接: utcz.com/qa/267202.html