当我按下我的注册按钮时,我的应用程序崩溃了
My application crashes when I press my signup Button
当我运行应用程序崩溃时(我是不是代码写错了)?
这是我的 post:
public class SignUP extends AppCompatActivity implements View.OnClickListener {
private EditText edtEmail,edtUserName, edtPassword;
private Button btnSignUp,btnLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
edtEmail = findViewById(R.id.edtEnterEmail);
edtUserName = findViewById(R.id.edtUserName);
edtPassword = findViewById(R.id.edtEnterPassword);
btnSignUp = findViewById(R.id.btnSignUp);
btnLogin = findViewById(R.id.btnLogin);
btnSignUp.setOnClickListener(this);
btnLogin.setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.btnSignUp:
final ParseUser appUser = new ParseUser();
appUser.setEmail(edtEmail.getText().toString());
appUser.setUsername(edtUserName.getText().toString());
appUser.setPassword(edtPassword.getText().toString());
appUser.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException e) {
if (e == null){
FancyToast.makeText(SignUP.this,appUser.getUsername() + "is signed up",
FancyToast.LENGTH_LONG, SUCCESS,true).show();
Intent intent = new Intent(SignUP.this,LoginActicvity.class);
startActivity(intent);
}else{
FancyToast.makeText(SignUP.this,"There was an error: "
+ e.getMessage(),FancyToast.LENGTH_LONG, ERROR,true).show();
}
}
});
break;
case R.id.btnLogin:
break;
}
}
}
这是我尝试 运行 应用程序时的错误:
java.lang.IllegalArgumentException:您必须使用 ParseObject.create() 或适当的子类创建这种类型的 ParseObject。
显示是这样的
确保您已在应用程序中初始化 Parse class。
// Register your parse models
ParseObject.registerSubclass(GameScore.class); // for example
Parse.enableLocalDatastore(this);
Parse.initialize(new Parse.Configuration.Builder(context)
.applicationId(APPLICATION_ID)
.server(SERVER)
.build()
);
您还需要创建一个 ParseObject
.
当我运行应用程序崩溃时(我是不是代码写错了)?
这是我的 post:
public class SignUP extends AppCompatActivity implements View.OnClickListener {
private EditText edtEmail,edtUserName, edtPassword;
private Button btnSignUp,btnLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
edtEmail = findViewById(R.id.edtEnterEmail);
edtUserName = findViewById(R.id.edtUserName);
edtPassword = findViewById(R.id.edtEnterPassword);
btnSignUp = findViewById(R.id.btnSignUp);
btnLogin = findViewById(R.id.btnLogin);
btnSignUp.setOnClickListener(this);
btnLogin.setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.btnSignUp:
final ParseUser appUser = new ParseUser();
appUser.setEmail(edtEmail.getText().toString());
appUser.setUsername(edtUserName.getText().toString());
appUser.setPassword(edtPassword.getText().toString());
appUser.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException e) {
if (e == null){
FancyToast.makeText(SignUP.this,appUser.getUsername() + "is signed up",
FancyToast.LENGTH_LONG, SUCCESS,true).show();
Intent intent = new Intent(SignUP.this,LoginActicvity.class);
startActivity(intent);
}else{
FancyToast.makeText(SignUP.this,"There was an error: "
+ e.getMessage(),FancyToast.LENGTH_LONG, ERROR,true).show();
}
}
});
break;
case R.id.btnLogin:
break;
}
}
}
这是我尝试 运行 应用程序时的错误:
java.lang.IllegalArgumentException:您必须使用 ParseObject.create() 或适当的子类创建这种类型的 ParseObject。
显示是这样的
确保您已在应用程序中初始化 Parse class。
// Register your parse models
ParseObject.registerSubclass(GameScore.class); // for example
Parse.enableLocalDatastore(this);
Parse.initialize(new Parse.Configuration.Builder(context)
.applicationId(APPLICATION_ID)
.server(SERVER)
.build()
);
您还需要创建一个 ParseObject
.