java - Displaying Array from Parse.com into ListView -
i have class in parse database looks this:

i wan't display in listview in activity shows every date , reps value, of current device. device yhmrkgokfs this:
-jul 05, 15
2/3-jul 05, 15
5/3/2/4/2-jul 05, 15
4/5/5/6/3
here code i'm using achieve this:
private listview displaylist; list<parseobject> store = new arraylist<parseobject>(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); displaylist = (listview)findviewbyid(r.id.displaylist); parsequery<parseobject> query = parsequery.getquery("workout"); query.whereequalto("device", parseinstallation.getcurrentinstallation()); query.setlimit(100); query.findinbackground(new findcallback<parseobject>() { @override public void done(list<parseobject> datalist, parseexception e) { // logic here store = datalist; } }); final arrayadapter<parseobject> arrayadapter = new arrayadapter<parseobject>( this, android.r.layout.simple_expandable_list_item_1, store ); displaylist.setadapter(arrayadapter); } however, list ends being empty. proper way of going displaying items parse database listview? gist of can't execute it, can write code me need do?
you passing store adapter change it's reference in done of findinbackground runs asynchronously adapter holds on empty list. should modify same instance of store. quick fix add in done
store.addall(datalist) and call adapter.notifydatasetchanged();
also default adapter use tostring() of each of object if want see useful, need create custom adapter.
Comments
Post a Comment