java - List View not populating dynamic objects at the right position -


i have custom list view has dynamic parts , pre defined portions. when populate it. static portions appear @ correct position in list view dynamic portions override !st of list view leaving part of layout in rest of postions blank. why happening?

this custom list view:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" >  <linearlayout     android:id="@+id/ll_list_items"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:orientation="vertical"     android:padding="10dp" >      <textview         android:id="@+id/txtvw_ch_item_label_name"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:text="@string/default_name"         android:textsize="17sp" />      <textview         android:id="@+id/txtvw_ch_item_label_number"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="+1956xxxxxxx" /> </linearlayout>  <linearlayout     android:layout_width="match_parent"     android:layout_height="2dp"     android:background="#03a3d9"     android:orientation="vertical" > </linearlayout> 

this getview part of code:

private class customlistadapter extends arrayadapter<string> {      context context;     layoutinflater inflater = null;     list<string> list_of_numbers = new arraylist<string>();      public customlistadapter(context ctx, int res_id, list<string> objects) {         super(ctx, res_id, objects);          context = ctx;         inflater = (layoutinflater) context                 .getsystemservice(context.layout_inflater_service);         (int = 0; < (objects.size()); i++) {              list_of_numbers.add(objects.get(i));         }      }      @override     public view getview(int position, view convertview, viewgroup parent) {          view vi = convertview;          if (vi == null) {             vi = inflater.inflate(r.layout.labels_listvw_item, null);         }          // lv_wrapper = (linearlayout) findviewbyid(r.id.ll_list_items);         linearlayout lv_wrapper = (linearlayout) findviewbyid(r.id.ll_list_items);         textview txt_number = (textview) vi                 .findviewbyid(r.id.txtvw_ch_item_label_number);         textview txt_name = (textview) vi                 .findviewbyid(r.id.txtvw_ch_item_label_name);          if (list_of_numbers.get(position).tostring() == null) {             list_of_numbers.get(position).replace(null, "");         }          list<string> list_of_other_columns = utils.checkforothercolumns(                 context, list_of_numbers.get(position).tostring());         log.d("", "logger name=" + txt_name.gettext());         (int = 0; < list_of_other_columns.size(); i++) {             log.d("", "logger posn is" + position);             // linearlayout lv_wrapper = (linearlayout)             // findviewbyid(r.id.ll_list_items);             textview label_txt = new textview(context);             // //             linearlayout.layoutparams label_text_params = new linearlayout.layoutparams(                     layoutparams.wrap_content, layoutparams.wrap_content);             // //             label_txt.setlayoutparams(label_text_params);             label_txt.settext(list_of_other_columns.get(i));             log.d("", "logger label for" + txt_name.gettext() + "="                     + label_txt.gettext());              // // log.d("", "logger lv_wrapper=" + lv_wrapper);             // lv_wrapper.addview(label_txt);+              if (lv_wrapper != null) {                  lv_wrapper.addview(label_txt);             }         }          txt_number.settext(list_of_numbers.get(position).tostring());          txt_name.settext(utils.getcontactname(context,                 list_of_numbers.get(position).tostring()));          return vi;     } } 


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -