android Parse.com获取特定数据

android Parse.com获取特定数据,android,parse-platform,Android,Parse Platform,这是我的截图 在我的activity.java中 btnSearchemail = (Button) findViewById(R.id.btnSearchemail); txtSearchemail = (EditText) findViewById(R.id.txtSearchemail); Searchemail = txtSearchemail.getText().toString(); txtFname = (TextView) findViewB

这是我的截图

在我的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();
                    }
                }
            });

        }
    });
btnSearchemail=(按钮)findviewbyd(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);
setOnClickListener(新的OnClickListener(){
公共void onClick(视图v){
final ParseQuery=ParseQuery
.getQuery(“账户”);
查询。whereEqualTo(“电子邮件”,Searchemail);
findInBackground(新的FindCallback(){
公共作废完成(列出结果,异常解析){
如果(e==null){
//结果包含找到的所有电子邮件的列表
for(解析对象x:结果){
String fname=x.getString(“firstName”);
String lname=x.getString(“lastName”);
}
//我在这里替换它这是编辑/更新的
txtFname.setText(fname);
txtLname.setText(lname);
}否则{
//错误
Toast.makeText(Sample.this.getApplicationContext(),
“错误”,Toast.LENGTH_LONG.show();
}
}
});
}
});

我想根据我放在编辑文本中的电子邮件检索特定数据。当我单击按钮时,不会再发生任何事情。

您需要调用查询。注意这个函数是异步的。可以找到文档

ParseQuery query=ParseQuery.getQuery(“账户”);
查询。whereEqualTo(“电子邮件”,emailsave);
findInBackground(新的FindCallback(){
公共作废完成(列出结果,异常解析){
如果(e==null){
//结果包含找到的所有电子邮件的列表
对于(ParseObject x:results){
String fname=x.getString(“firstName”);
String lname=x.getString(“lastName”);
//把断点放在这里,看看变量包含什么
txtFname.setText(fname);
txtLname.setText(lanme)
}
}否则{
//错误
}
}
});

我想显示给定行的firstname和lastname,如何显示?如果(e==null){String fname=query.get(“firstname”);String lname=query.get(“lastname”);txtFname.setText(fname);txtFname.setText(lanme);^这只是一个例子,更新了答案。阅读文档将对您有很大帮助。我无法告诉您,没有项目它为什么不起作用。我给您的代码应该起作用。如果您在其中添加断点,那么您可以看到哪些部分出了问题,并且在问题中更加清楚。
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
        }
    }
});