android - notifyDatasetChanged() not working on the adapter -
i've created custom list 4 textviews...the data in list saved through dialog has ok button. when add data, gets saved in list(works fine till now). when add next element, rows gets same value last one...the notifydatasetchanged() not working...am wrong somewhere?...this code...
ok.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { string val = editquantity.gettext().tostring(); valq1 = integer.parseint(val); listview l; l = (listview) v.findviewbyid(r.id.order_listview); myadapter adapter = new myadapter(getactivity(), row); l.setadapter(adapter); row.add(""); adapter.notifydatasetchanged(); builder.dismiss(); } }); builder.setview(dialog); builder.show();
you created new adapter everytime click ok. put adapter code outside onclick method:
listview l = (listview) v.findviewbyid(r.id.order_listview); myadapter adapter = new myadapter(getactivity(), row); l.setadapter(adapter); ok.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { string val = editquantity.gettext().tostring(); valq1 = integer.parseint(val); row.add(""); //add new item list adapter.notifydatasetchanged(); //notify adapter builder.dismiss(); } }); builder.setview(dialog); builder.show();
Comments
Post a Comment