android - ListView not inflating -


good day all.

i working on customized listview not inflating (is not becoming visible) inside activity.

below xml , listview adapter classes.

main.xml

<linearlayout      android:id="@+id/lllistview"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:paddingleft="5dp"     android:paddingright="5dp"     android:paddingtop="2dp"     android:paddingbottom="2dp"     android:layout_below="@+id/rlfirstrow">      <listview          android:id="@+id/lverrorsreport"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:background="@drawable/border"/>  </linearlayout> 

listview_row.xml

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent">  <linearlayout     android:id="@+id/llerror"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:orientation="horizontal"     android:layout_alignparenttop="true">      <textview         android:id="@+id/txterrorinfo"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text=""         android:textstyle="bold"         android:textsize="20dp"/>  </linearlayout>      <linearlayout     android:id="@+id/llstatus"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:orientation="horizontal"     android:layout_below="@+id/llerror">      <textview         android:id="@+id/txtstatus"         android:layout_width="100dp"          android:layout_height="wrap_content"         android:text="status: "/>      <textview         android:id="@+id/txtstatusinfo"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text=""         android:textstyle="italic"/>  </linearlayout>     <linearlayout     android:id="@+id/llmaterials"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:orientation="horizontal"     android:layout_below="@+id/llstatus">      <textview         android:id="@+id/txtmaterials"         android:layout_width="100dp"          android:layout_height="wrap_content"         android:text="materials: "/>      <textview         android:id="@+id/txtmaterialsinfo"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text=""         android:textstyle="italic"/>  </linearlayout>     <linearlayout    android:id="@+id/llbutton"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:orientation="horizontal"    android:layout_below="@+id/llmaterials">     <button         android:id="@+id/btnshowmaterials"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="show materials"        android:visibility="gone"/>    </linearlayout>  </relativelayout> 

baseadapter class

public class repairreportlistviewadapter extends baseadapter  { arraylist<string> errors; arraylist<string> statuses; arraylist<boolean> materials; context mcontext; layoutinflater inflater;  public repairreportlistviewadapter(context context, arraylist<string> err, arraylist<string> stat, arraylist<boolean> mat) {     this.mcontext = context;     this.errors = err;     this.statuses = stat;     this.materials = mat;      inflater = (layoutinflater)mcontext.getsystemservice(context.layout_inflater_service); }  @override public int getcount() {     return 0; }  @override public object getitem(int position) {     return null; }  @override public long getitemid(int position)  {     return 0; }  @override public view getview(int position, view convertview, viewgroup parent) {     viewholder holder;      if(convertview == null)     {         holder = new viewholder();          convertview = inflater.inflate(r.layout.repairreport_listview, null);          holder.error = (textview)convertview.findviewbyid(r.id.txterrorinfo);         holder.status = (textview)convertview.findviewbyid(r.id.txtstatusinfo);         holder.material = (textview)convertview.findviewbyid(r.id.txtmaterialsinfo);         holder.showmaterials = (button)convertview.findviewbyid(r.id.btnshowmaterials);          convertview.settag(holder);     }     else     {         holder = (viewholder)convertview.gettag();     }      holder.error.settext(this.errors.get(position).tostring());     holder.status.settext(this.statuses.get(position).tostring());      if(this.materials.get(position) == true)     {         holder.material.settext("materials used fix error. click on button below view materials.");         holder.showmaterials.setvisibility(button.visible);         holder.showmaterials.setonclicklistener(new view.onclicklistener()         {                    @override             public void onclick(view v)              {                 //later             }         });     }     else     {         holder.material.settext("no materials used fix error.");     }      return convertview; }  static class viewholder {     textview error;     textview status;     textview material;     button showmaterials; }     } 

i've tried changing layouts suggested here listview still not revealed.

any ideas why not showing? sorry code dump cannot figure out heck going on.

p.s. did set adapter listview in main activity.

    adapter = new repairreportlistviewadapter(this, errornames, statuses, materialsinuse);     lverrors.setadapter(adapter); 

your listview not inflate nothing because getcount returning 0

change

@override public int getcount() {     return 0; } 

with

@override public int getcount() {     return (stat == null) ? 0 : stat.size(); } 

also, instead of keeping 3 differents arraylist, can create class holds info need , arraylist of class


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -