我在解析数据库中将用户添加到我的User类时出现问题。我在用户表中重新启动parse.com网页后的唯一结果是
用户
android.support.v7.widget.AppCompatEditText {258e641a VFED..CL ........ 20,68-684,159#7f0c0051 app:id / userloginname}
Bankgo
Maniw
我希望下一个User字段是用户输入的内容,与某些生成的ID相对。我有点困惑。有人可以帮助我吗?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(layout.activity_login);
final EditText username = (EditText) this.findViewById(id.userloginname);
final EditText password = (EditText) this.findViewById(id.userpassword);
TextView neighbourView = new TextView(this);
Button button_test;
button_test = (Button) this.findViewById(id.btnLogin);
button_test.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
final String usersname = username.getText().toString();
final String passwoord = password.getText().toString();
ParseUser user = new ParseUser();
user.setUsername(String.valueOf(username));
user.setPassword(String.valueOf(password));
user.signUpInBackground(new SignUpCallback() {@Override
public void done(com.parse.ParseException e) {
if (e != null) {
ParseUser.logInInBackground(usersname, passwoord, new LogInCallback() {
public void done(ParseUser User, com.parse.ParseException e) {
if (User != null) {
// user name is in the database
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
} else {
Toast.makeText(getApplicationContext(), "user name does not exists", Toast.LENGTH_LONG).show();
}
}
});
}
}
});
}
});
}
});
}
我的XML
<!-- language: xml -->
<!-- Username Label -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="@string/username"/>
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:layout_marginBottom="20dip"
android:singleLine="true"
android:id="@+id/userloginname"
android:inputType="text" />
<!-- Password Label -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="@string/password"/>
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:singleLine="true"
android:password="true"
android:inputType="textPassword"
android:id="@+id/userpassword" />
<!-- Login button -->
<Button android:id="@+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="@string/loginButton"/>
答案 0 :(得分:0)
更改此
user.setUsername(String.valueOf(username));
user.setPassword(String.valueOf(password));
到
user.setUsername(String.valueOf(usersname ));
user.setPassword(String.valueOf(passwoord));
您正在混合真实文本和textview的等效字符串。