How to set same appearance for dynamically created custom listview in android? -
i'm getting problem in setting equal width space elements of dynamically created custom listview in fragment. elements arranged in same listview. please give idea how make unique in custom view.please see image. me. in advance!!!!
code ------>
<?xml version="1.0" encoding="utf-8"?> <tablelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <tablerow> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="20dp" android:textsize="18sp" android:textcolor="#800080" android:id="@+id/txt1"> </textview> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="20dp" android:textsize="18sp" android:textcolor="#800080" android:id="@+id/txt2"> </textview> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="20dp" android:textsize="18sp" android:textcolor="#800080" android:id="@+id/txt3"> </textview> <button android:id="@+id/del_button" android:text="delete" android:layout_width="wrap_content" android:layout_height="match_parent" android:onclick="additems" android:layout_gravity="right" android:theme="@style/mybutton"/> </tablerow>
i think better idea use gridview. did not provide listview`s code think tablelayot , tablerow useless. anyways can try put textviews , button in linearlayout , give them weights. fore example, give them equal space:
<linearlayout android:id="@+id/horizontal_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightsum="4" > <textview android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:padding="20dp" android:textsize="18sp" android:textcolor="#800080" android:id="@+id/txt1"> </textview> <textview android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:padding="20dp" android:textsize="18sp" android:textcolor="#800080" android:id="@+id/txt2"> </textview> <textview android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:padding="20dp" android:textsize="18sp" android:textcolor="#800080" android:id="@+id/txt3"> </textview> <button android:id="@+id/del_button" android:text="delete" android:layout_width="wrap_content" android:layout_height="match_parent" android:onclick="additems" android:layout_gravity="right" android:theme="@style/mybutton" android:layout_width="0dp" android:layout_weight="1" /> </linearlayout>
Comments
Post a Comment