I am hosting a Parse server that holds data containing plants. I have no errors in my code but it doesn't seem to fetch any data. I want the query to equal the contents of 'name'. For example if 'name' contains "Daisy" it will find the data for that flower and display the selected information. Here is my code:
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();
}
}
Use findInBackground()
with callback
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);
}
}
});