android - Fill parent not working on My list view -
here xml code.
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#e7f7ff" android:gravity="top"> <!-- header text here --> <textview /> <!-- scrollable layout --> <scrollview > <relativelayout android:layout_height="fill_parent" android:layout_margintop="5dip" android:layout_width="fill_parent"> <linearlayout > <imageview /> </linearlayout> <linearlayout > <textview /> <textview /> <framelayout android:layout_width="fill_parent" android:layout_height="wrap_content"> <listview android:id="@+id/contact_number_list_view" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="fill_parent" android:layout_margintop="3dp" android:layout_marginbottom="1dp" android:layout_marginright="5dip" android:clickable="true" android:cachecolorhint="#00000000" android:divider="@android:color/transparent" android:dividerheight="2dip" android:fastscrollenabled="true" android:fadescrollbars="true" android:listselector="@drawable/rounded_corner_item_selecter" android:layout_gravity="top"></listview> <textview /> </framelayout> </linearlayout> <!-- show tags details layout --> <linearlayout > <tablelayout > </tablelayout> </linearlayout> </relativelayout> </scrollview> <!-- button layouts here --> <linearlayout > <button /> <button/> <button /> </linearlayout> </relativelayout>
and want expand list view number of data in it. not expand in size. why?
as explained programmers did listview in video googleio never put listview inside scroll view. if list should not scroll use viewgroup linear layout , add items viewgroup in loop in code. if want whole row clickable have use viewgroup root node each row , add onclicklistener view.
so replace listview
linearlayout
<linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linear_layout_which_is_present_at_place_of_list_view" android:orientation="vertical"/> <textview android:layout_height="wrap_content" android:layout_width="wrap_content"/>
and let using 2 textview custom row of list view. custom row view row_view_layout.xml
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <textview android:layout_width="wrap_content" android:clickable="true" android:id="@+id/row_view_layout_text1" android:layout_height="wrap_content" /> <textview android:id="@+id/row_view_layout_text2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clickable="true"/> </linearlayout>
sample code:
//let using 2 textview custom row of list view. linearlayout list = (linearlayout)findviewbyid(r.id.linear_layout_which_is_present_at_place_of_list_view); layoutinflater inflater = layoutinflater.from(context); list.removeallviews(); //remove created views for(string row : getallrow()) { view vi = inflater.inflate(r.layout.row_view_layout, null); textone = (textview) vi.findviewbyid(r.id.row_view_layout_text1); texttwo = (textview) vi.findviewbyid(r.id.row_view_layout_text2); final string t1 = row.getfirstvalue(); final string t2 = row.getsecondvalue(); textone.settext(t1); texttwo.settext(t2); //set listener both text views textone.setonclicklistener(new onclicklistener() { public void onclick(view v) { toast.maketext(context, "you clicked on : " + t1 , toast.length_short).show(); } }); texttwo.setonclicklistener(new onclicklistener() { public void onclick(view v) { toast.maketext(context, "you clicked on : " + t2 , toast.length_short).show(); } }); //add view list.addview(vi); }
hope help.
happy coding.
Comments
Post a Comment