这是我的截图
在我的activity.java
中 btnSearchemail = (Button) findViewById(R.id.btnSearchemail);
txtSearchemail = (EditText) findViewById(R.id.txtSearchemail);
Searchemail = txtSearchemail.getText().toString();
txtFname = (TextView) findViewById(R.id.txtFname);
txtLname = (TextView) findViewById(R.id.txtLname);
btnSearchemail.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
final ParseQuery<ParseObject> query = ParseQuery
.getQuery("account");
query.whereEqualTo("email", Searchemail);
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> results, ParseException e) {
if (e == null) {
// results contains a list of all the emails found
for (ParseObject x : results) {
String fname = x.getString("firstName");
String lname = x.getString("lastName");
}
// i replace it here this is edited/updated
txtFname.setText(fname);
txtLname.setText(lname);
} else {
// error
Toast.makeText(Sample.this.getApplicationContext(),
"error", Toast.LENGTH_LONG).show();
}
}
});
}
});
我想根据我在编辑文本中添加的电子邮件检索特定数据。单击按钮时没有任何反复发生。
答案 0 :(得分:0)
您需要调用查询。注意这个函数是异步的。可以找到文档here。
ParseQuery<ParseObject> query = ParseQuery.getQuery("account");
query.whereEqualTo("email", emailsave);
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> results, ParseException e) {
if (e == null) {
// results contains a list of all the emails found
for (ParseObject x : results) {
String fname = x.getString("firstName");
String lname = x.getString("lastName");
// Put breakpoint here and see what the variables contain
txtFname.setText(fname);
txtLname.setText(lanme)
}
} else {
// error
}
}
});