android - Duplicate elements in a listview -


i of sudden getting duplicate elements in listview. when onclick action on list items, comes normal. checked adapter, not adding multiple items in arraylist. can possibly wrong here.

public view getview(int position, view convertview, viewgroup parent) {         if (convertview == null || convertview.gettag() == null) {             convertview = inflater.inflate(r.layout.bookingresponse_row, null);             final cabbieviewholder viewholder = new cabbieviewholder();             viewholder.call = (imageview) convertview.findviewbyid(r.id.callcab);             viewholder.call.setonclicklistener(this);             viewholder.drivername = (textview) convertview.findviewbyid(r.id.drivername);             //similar code more data items              convertview.settag(viewholder);         }         // setting values in listview         string temp = latestacceptedcabbiename.get(position);         ((cabbieviewholder) (convertview.gettag())).drivername.settext(temp);         ((cabbieviewholder) (convertview.gettag())).indetailsdrivername.settext(temp);          //simiar code other data items         // smoothen out list         new asynctask<object, void, float>() {             cabbieviewholder cabbieviewholder;              @override             protected float doinbackground(object... params) {                 float cabdistancefromcustomer = -1.0f;                 cabbieviewholder = (cabbieviewholder) params[0];                 if (cabbieviewholder.distancefromcustomer == -1.0f) {                     int position = (int) ((integer) params[1]).intvalue();                     cabbieviewholder.distancefromcustomer = cabdistancefromcustomer = god                             .getgeodistance(double.valueof(latestacceptedcabbiesourcegpsx                                     .get(position)), double                                     .valueof(latestacceptedcabbiesourcegpsy.get(position)),                                     double.valueof(customersourcelat / 1e6), double                                             .valueof(customersourcelng / 1e6));                 } else                     cabdistancefromcustomer = cabbieviewholder.distancefromcustomer;                 return cabdistancefromcustomer;             }              @override             protected void onpostexecute(float result) {                 super.onpostexecute(result);                 if (customersourcelat != 0 && customersourcelng != 0) {                     string temp;                     if (result != 0) {                         temp = "current location @ approx "                                 + string.format("%.1f", result / 1000) + " km";                         cabbieviewholder.cabdistance.settext(temp);                         cabbieviewholder.indetailscabdistance.settext(temp);                     } else {                         cabbieviewholder.cabdistance.setvisibility(view.gone);                         cabbieviewholder.indetailscabdistance.setvisibility(view.gone);                     }                 } else {                     cabbieviewholder.cabdistance.setvisibility(view.gone);                     cabbieviewholder.indetailscabdistance.setvisibility(view.gone);                 }             }         }.execute((cabbieviewholder) convertview.gettag(), new integer(position));         return convertview;     } 

i see loading content in asynchronous task. if task has not completed yet see old content.

try putting "loading data" indicator in view know data stale in else block executes when convertview not null.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -