Separator missing out between list items in Android -


i have used custom array adapter populate list view.the problem face separator missing out in between fourth , fifth list item.

here's code:

public class clubs extends listactivity{      private static class efficientadapter extends baseadapter {         private layoutinflater minflater;         private bitmap micon1;         private bitmap micon2;          public efficientadapter(context context) {             // cache layoutinflate avoid asking new 1 each time.             minflater = layoutinflater.from(context);              // icons bound rows.             micon1 = bitmapfactory.decoderesource(context.getresources(), r.drawable.yellow_offline);             micon2 = bitmapfactory.decoderesource(context.getresources(), r.drawable.green_online);         }          /**          * number of items in list determined number of speeches          * in our array.          *          * @see android.widget.listadapter#getcount()          */         public int getcount() {             return data.length;         }          /**          * since data comes array, returning index          * sufficent @ data. if using more complex data          * structure, return whatever object represents 1 row in          * list.          *          * @see android.widget.listadapter#getitem(int)          */         public object getitem(int position) {             return position;         }          /**          * use array index unique id.          *          * @see android.widget.listadapter#getitemid(int)          */         public long getitemid(int position) {             return position;         }          /**          * make view hold each row.          *          * @see android.widget.listadapter#getview(int, android.view.view,          *      android.view.viewgroup)          */         public view getview(int position, view convertview, viewgroup parent) {             // viewholder keeps references children views avoid unneccessary calls             // findviewbyid() on each row.             viewholder holder;              // when convertview not null, can reuse directly, there no need             // reinflate it. inflate new view when convertview supplied             // listview null.             if (convertview == null) {                 convertview = minflater.inflate(r.layout.people_list_item, null);                  // creates viewholder , store references 2 children views                 // want bind data to.                 holder = new viewholder();                 holder.text = (textview) convertview.findviewbyid(r.id.textpeople);                 holder.icon = (imageview) convertview.findviewbyid(r.id.image);                  convertview.settag(holder);             } else {                 // viewholder fast access textview                 // , imageview.                 holder = (viewholder) convertview.gettag();             }              // bind data efficiently holder.             holder.text.settext(data[position]);             holder.icon.setimagebitmap((position & 1) == 1 ? micon1 : micon2);              return convertview;         }          static class viewholder {             textview text;             imageview icon;         }     }      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setlistadapter(new efficientadapter(this));     }      private static final string[] data = {             "abbaye de belloc", "abbaye du mont des cats", "abertam",             "abondance", "ackawi", "acorn", "adelost", "affidelice au chablis",             }; } 

here's xml:

<?xml version="1.0" encoding="utf-8"?> <linearlayout android:id="@+id/widget31" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" xmlns:android="http://schemas.android.com/apk/res/android" >  <linearlayout android:id="@+id/widget321" android:layout_width="479dip" android:layout_height="54dip" android:layout_margintop="16dip" >  <imageview android:id="@+id/image" android:layout_width="24dip" android:layout_height="24dip" android:layout_marginleft="14dip" android:layout_margintop="5dip" android:src="@drawable/green_online"> </imageview>  <textview android:id="@+id/textpeople" android:layout_marginleft="10dip" android:textcolor="#fff5ee"  android:layout_height="29dip"  android:textsize="16sp"  android:layout_width="400dip"  android:layout_margintop="7dip" > </textview> </linearlayout> </linearlayout> 

here screen shot listseparator

can tell me have gone wrong? thanks

edit:
solution:
here's code added working

listview lv=getlistview();  lv.setdividerheight(2);  

the easy way call setdividerheight(2) in oncreate method. in more complicated way, need make sure resources correctly put in layout-hdpi / layout because what's happening there os approximates 1dpi 0dpi because app runs in compatibility mode. check out supports-screens attribute in manifest (try setting true)


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -