java - ListView getting populated with the same data twice? -
i have list view displays data based on text change.however same data displayed twice.for example if list contains single 'apple' list contain 2 apple's. i.e. same entry twice.
this code :-
private void showdocno(string response) { parseadvopen pao = new parseadvopen(response); pao.parsejson(); list<map<string, string>> dn_info = new arraylist<map<string, string>>(); map<string, string> dn_map; int counts = parseadvopen.adv_no.length; (int = 0; < counts; ++i) { dn_map = new hashmap<>(); dn_map.put("doc_no", parseadvopen.adv_no[i]); dn_map.put("date", parseadvopen.date[i]); dn_map.put("cust_name", parseadvopen.cust_name[i]); dn_map.put("cust_number", parseadvopen.cust_number[i]); dn_map.put("item_count", parseadvopen.item_count[i]); dn_map.put("total", parseadvopen.sum_total[i]); dn_map.put("paid", parseadvopen.paid[i]); dn_info.add(dn_map); } dnadapter = new simpleadapter(getactivity().getapplicationcontext(), dn_info, r.layout.list_docno, new string[]{"doc_no", "cust_name", "cust_number"}, new int[]{r.id.textviewdn, r.id.customer_name, r.id.customer_mobile}); doc_list.setadapter(dnadapter); log.d("dninfo", dn_info.tostring()); inputsearch.addtextchangedlistener(new textwatcher() { @override public void beforetextchanged(charsequence s, int start, int count, int after) { doc_list.setvisibility(view.invisible); advopen_list.setvisibility(view.visible); searchlayout.setvisibility(view.gone); } @override public void ontextchanged(charsequence s, int start, int before, int count) { doc_list.setvisibility(view.visible); } @override public void aftertextchanged(editable s) { if (s.length() == 0) { doc_list.setvisibility(view.invisible); } else { dnadapter.getfilter().filter(s); doc_list.setvisibility(view.visible); } } }); doc_list.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { map docselected = (map) dnadapter.getitem(position); string doc_number = (string) docselected.get("doc_no"); string date = (string) docselected.get("date"); string customername = (string) docselected.get("cust_name"); string mobileno = (string) docselected.get("cust_number"); string icount = (string) docselected.get("item_count"); string total = (string) docselected.get("total"); string paid = (string) docselected.get("paid"); log.d("document selected", doc_number + " " + customername + " " + mobileno + " " + date); advopen_list.setvisibility(view.gone); doc_list.setvisibility(view.gone); searchlayout.setvisibility(view.visible); tv_docno.settext(doc_number); tv_date.settext(date); tv_name.settext(customername); tv_mobile.settext(mobileno); tv_itemcount.settext(icount); tv_tot.settext(total); tv_paid.settext(paid); } }); }
this method gets called on response of volley request mysql database.
any or suggestion appreciated.thank you.
Comments
Post a Comment