android - Listview displays only one row from the list -
i new android listviews , trying populate listview in android list of items coming webservice. know list contains more 1 record coming webservice custom listview displays first record list. checked size of list , there more 1 records listview showing 1 of them. custom adapter following:
public class listadapter extends baseadapter { context ctx; layoutinflater linflater; arraylist<litem> lstitems; listadapter(context context, arraylist<litem> objects) { ctx = context; lstitems = objects; linflater = (layoutinflater) ctx .getsystemservice(context.layout_inflater_service); } @override public int getcount() { return lstitems.size(); } @override public object getitem(int position) { return lstitems.get(position); } @override public long getitemid(int position) { return position; } @override public view getview(int position, view convertview, viewgroup parent) { view view = convertview; if (view == null) { view = linflater.inflate(r.layout.list_style_task , parent, false); } litem p = getproduct(position); ((textview) view.findviewbyid(r.id.tvmaterial )).settext(p.getmname() ); ((textview) view.findviewbyid(r.id.tvtask )).settext(p.gettname() ); ((textview) view.findviewbyid(r.id.tvbquantity )).settext(p.getbq() ); // checkbox cbbuy = (checkbox) view.findviewbyid(r.id.checkbox); //cbbuy.setoncheckedchangelistener(mycheckchanglist); // cbbuy.settag(position); // cbbuy.setchecked(p.selected); return view; } litem getproduct(int position) { return ((litem) getitem(position)); } arraylist<litem> getbox() { arraylist<litem> box = new arraylist<litem>(); (litem p : lstitems) { // if (p.selected) // box.add(p); } return box; } oncheckedchangelistener mycheckchanglist = new oncheckedchangelistener() { public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { //getproduct((integer) buttonview.gettag())= ischecked; } }; }
i binding listview as:
protected void onpostexecute(list<litem> li ) { super.onpostexecute(lstitm); if(lstitm.size()>0) { adp=new listadapter(myactivity,lstitm); lvtasks.setadapter(adp); log.d("size---------",integer.tostring(lstitm.size()) );//here writes more 1 size of list. } }
my xml file displaying lists this:
<?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="match_parent" android:orientation="vertical" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginleft="20dp" android:layout_marginright="20dp" > <checkbox android:id="@+id/checkbox1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:focusable="false" android:textcolor="#fff" android:button="@drawable/custom_checkbox_design" android:focusableintouchmode="false" android:text="" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="task:" android:id="@+id/textview2" android:layout_weight="1" android:textcolor="#fff" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="task" android:id="@+id/tvtask" android:layout_weight="1" android:textcolor="#fff" /> </linearlayout> <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="45dp" android:layout_marginright="20dp" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="material:" android:id="@+id/textview1" android:layout_weight="1" android:textcolor="#fff" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="material" android:id="@+id/tvmaterial" android:layout_weight="1" android:textcolor="#fff" /> </linearlayout> <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginleft="45dp" android:layout_marginright="20dp" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="balanced quantity:" android:id="@+id/textview14" android:layout_weight="1" android:textcolor="#fff" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="bquantity" android:id="@+id/tvbquantity" android:layout_weight="1" android:textcolor="#fff" /> </linearlayout> <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="45dp" android:layout_marginright="20dp"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="adjust balanced quantity:" android:id="@+id/textview25" android:layout_weight="1" android:textcolor="#fff" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" android:id="@+id/tvaquantity" android:layout_weight="1" android:textcolor="#fff" /> </linearlayout> </linearlayout>
my xml listview this:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="kanix.highrise.com.highrise.generate_material_requisition"> <!-- todo: update blank fragment layout --> <scrollview android:id="@+id/scrlview" android:layout_width="fill_parent" android:layout_height="fill_parent" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <listview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/lsttaskquantity" android:layout_weight="1" > </listview> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp"> <textview android:id="@+id/txtlddsdfabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerinparent="true" android:textsize="16dp" android:text="req. :" android:layout_weight="1" android:textcolor="#fff" /> <edittext android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputtype="date" android:id="@+id/etdate" android:layout_weight=".5" android:hint="dd/mm/yyyy"/> <imagebutton android:layout_width="35dp" android:layout_height="35dp" android:id="@+id/btnimgcal" android:src="@drawable/calender" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp"> <textview android:id="@+id/txtlddsdfadsbel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerinparent="true" android:textsize="16dp" android:text="for days :" android:layout_weight="1" android:textcolor="#fff" /> <edittext android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputtype="number" android:text="0" android:id="@+id/edittext" android:layout_weight="1.69" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp"> <textview android:id="@+id/txtlddsddfgfadsbel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerinparent="true" android:textsize="16dp" android:text="quantity :" android:layout_weight="1" android:textcolor="#fff" /> <edittext android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputtype="number" android:text="0" android:id="@+id/etquantity" android:layout_weight="1.60" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:layout_gravity="center" android:orientation="vertical" > <button android:layout_width="fill_parent" android:layout_height="wrap_content" android:textcolor="#0080ff" android:background="#fff" android:text="generate requisition" android:id="@+id/btnsave" /> </linearlayout> </linearlayout> </scrollview> </linearlayout>
issue scrollview createing issue. removed
<scrollview android:id="@+id/scrlview" android:layout_width="fill_parent" android:layout_height="fill_parent" > </scrollview>
and worked me :)
Comments
Post a Comment