我有一个用户数据库,我想添加一个新列(fullname(string))。
以下是代码:
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.PopupWindow;
import android.widget.Toast;
import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SignUpCallback;
import comevidentia.wix.evidentia.www.krudyapp.R;
public class RegisterActivity extends AppCompatActivity {
Button signup;
String usernametxt;
String passwordtxt;
String emailtxt;
String fullnametxt;
EditText fullname;
EditText password;
EditText username;
EditText email;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
final ImageButton btnOpenPopup2 = (ImageButton)findViewById(R.id.openpopup2);
btnOpenPopup2.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View arg0) {
LayoutInflater layoutInflater
= (LayoutInflater) getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.activity_popup2, null);
final PopupWindow popupWindow = new PopupWindow(
popupView,
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
Button btnDismiss = (Button) popupView.findViewById(R.id.dismiss);
btnDismiss.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
popupWindow.dismiss();
}
});
popupWindow.showAsDropDown(btnOpenPopup2, 50, -30);
}
});
final ImageButton btnOpenPopup3 = (ImageButton)findViewById(R.id.openpopup3);
btnOpenPopup3.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
LayoutInflater layoutInflater
= (LayoutInflater)getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.activity_popup3, null);
final PopupWindow popupWindow = new PopupWindow(
popupView,
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
Button btnDismiss = (Button)popupView.findViewById(R.id.dismiss);
btnDismiss.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
popupWindow.dismiss();
}});
popupWindow.showAsDropDown(btnOpenPopup3, 50, -30);
}});
// Locate EditTexts in main.xml
fullname = (EditText) findViewById(R.id.fullname);
username = (EditText) findViewById(R.id.username);
password = (EditText) findViewById(R.id.password);
email = (EditText) findViewById(R.id.email);
signup = (Button) findViewById(R.id.signup);
// Sign up Button Click Listener
signup.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// Retrieve the text entered from the EditText
fullnametxt = fullname.getText().toString();
usernametxt = username.getText().toString();
passwordtxt = password.getText().toString();
emailtxt = email.getText().toString();
// Force user to fill up the form
if (fullnametxt.equals("") && usernametxt.equals("") && passwordtxt.equals("") && emailtxt.equals("")) {
Toast.makeText(getApplicationContext(),
"Kérlek töltsd ki az űrlapot!",
Toast.LENGTH_LONG).show();
} else {
// Save new user data into Parse.com Data Storage
ParseUser user = new ParseUser();
user.setFullname(fullnametxt);
user.setUsername(usernametxt);
user.setPassword(passwordtxt);
user.setEmail(emailtxt);
user.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
if (e == null) {
// Show a simple Toast message upon successful registration
Toast.makeText(getApplicationContext(),
"Sikeres regisztrálás! Lépj be!",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(),
"Regisztrációs hiba", Toast.LENGTH_LONG)
.show();
}
}
});
}
}
});
}
我收到错误:
//将新用户数据保存到Parse.com数据存储
ParseUser user = new ParseUser();
user.setFullname(fullnametxt);
// setFullname =我收到错误:
我想在数据库中添加全名。
我该怎么做?
我只能添加用户名,电子邮件,密码 - >它是基本的 - >我在这里找到了它:https://parse.com/docs/android/api/com/parse/ParseUser.html#setUsername%28java.lang.String%29
我正在使用Android Studio。
谢谢!
答案 0 :(得分:0)
答案 1 :(得分:0)
检查此答案..
ParseUser user = new ParseUser();
user.setEmail(emai.getText().toString());
user.setUsername(emai.getText().toString());
user.setPassword(password.getText().toString());
user.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException er) {
if (er != null) {
Log.e("ERROR",er.getMessage().toString());
Toast.makeText(Form.this,"User Already login are exist!",Toast.LENGTH_LONG).show();
} else {
Log.e("hello","New User Are Add Informatin");
}
}
});
此代码在解析表中添加新用户。