使用 Parse 后端填充 TextView

Populating TextViews with Parse backend

我正在托管一个包含植物数据的 Parse 服务器。我的代码没有错误,但它似乎没有获取任何数据。我希望查询等于 'name' 的内容。例如,如果 'name' 包含 "Daisy",它将查找该花的数据并显示所选信息。这是我的代码:

public class mygardenDetail extends Activity {

String name;
String kgsays;
String care;
String tips;
String image;
ImageLoader imageLoader = new ImageLoader(this);
List<ParseObject> ob;
private List<PlantListitems> plantlist = null;

@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.mygarden_detail);


Intent i = getIntent();
name = i.getStringExtra("name");



// Locate the TextViews in singleitemview.xml

TextView txtName = (TextView) findViewById(R.id.name);
TextView txtKGsays = (TextView) findViewById(R.id.KGsays);
TextView txtCare = (TextView) findViewById(R.id.Care);
TextView txtTips = (TextView) findViewById(R.id.Tips);

// Locate the ImageView in singleitemview.xml
ImageView imgflag = (ImageView) findViewById(R.id.image);
txtName.setText(name);


// Capture position and set results to the ImageView
// Passes flag images URL into ImageLoader.class
   imageLoader.DisplayImage(image, imgflag);



    try {
    ParseQuery query = new ParseQuery<>("Plants2");
    query.whereMatches("plantName", String.valueOf(equals(name)));
    ob = query.find();

    for (ParseObject country : ob) {
                // Locate images in flag column
                ParseFile image = (ParseFile) country.get("image");

                //PlantListitems map = new PlantListitems();
                txtKGsays.setText((String) country.get("KGsays"));
                txtCare.setText((String) country.get("Care"));
                txtTips.setText((String) country.get("tips"));
                //imgflag.DisplayImage(image.getUrl());
                //plantlist.add(map);
            }
} catch (ParseException e) {
    e.printStackTrace();
}
        } 

使用 findInBackground() 回调

ParseQuery query = new ParseQuery<>("Plants2");
query.whereEqualTo("plantName", (name));
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> listCountry, ParseException e) {
   for (ParseObject country : listCountry) {
            // Locate images in flag column
            ParseFile image = (ParseFile) country.get("image");

            //PlantListitems map = new PlantListitems();
            txtKGsays.setText((String) country.get("KGsays"));
            txtCare.setText((String) country.get("Care"));
            txtTips.setText((String) country.get("tips"));
            //imgflag.DisplayImage(image.getUrl());
            //plantlist.add(map);
        }
}
});