android - How to populate a ListView with Parse Array using ArrayAdapter -
so i'm new android , i'm using parse backend. have array column in parse called prescriptionarray. want take contents of array (string values) , populate listview them. think i'm missing couple of lines not sure where? appreciated.. in advance!
public class prescriptionsarrayactivity extends appcompatactivity { private listview lvprescriptions; private edittext etmedicalid; private arrayadapter<string> adapter ; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_prescriptions_array); lvprescriptions = (listview) findviewbyid(r.id.lvprescriptions); etmedicalid = (edittext) findviewbyid(r.id.etmedicalid); //get medical id number previous activity bundle bundle = getintent().getextras(); string str = bundle.getstring("medicalid"); toast.maketext(getbasecontext(), str, toast.length_long).show(); etmedicalid.settext(str); final list<string> arrayprescription = new arraylist<string>(); final arrayadapter adapter = new arrayadapter(prescriptionsarrayactivity.this, android.r.layout.simple_list_item_1, arrayprescription); final parsequery<parseobject> query = parsequery.getquery("prescriptionobject"); query.whereequalto("medicalid", etmedicalid.gettext().tostring()); query.findinbackground(new findcallback<parseobject>() { public void done(list<parseobject> prescriptionlist, parseexception e) { if (e == null) { (int = 0; < prescriptionlist.size(); i++) { parseobject p = prescriptionlist.get(i); if (p.getlist("prescriptionarray") != null) { string s = arrayprescription.tostring(); adapter.addall(arrays.aslist(s)); } } lvprescriptions.setadapter(adapter); } } }); } }
Comments
Post a Comment