PDA

View Full Version : ایجاد header برای لیست ویو چند ستونی



rezaei_y
یک شنبه 30 شهریور 1393, 11:33 صبح
با سلام

من یک لیست ویو دارم که 4 تا ستون داره اطلاعات رو هم توی چهار ستون نمایش میده حالا میخوام ستون هام عنوان داشته باشن چطور باید این کار رو انجام بدم



<?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" >
<ListView
android:id="@+id/booklist"
android:rotationY="180"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>


</LinearLayout>

rezaei_y
یک شنبه 30 شهریور 1393, 12:36 عصر
ممنون دوستان
راه حلش خیلی ساده بود


<?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="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#fff"

>
<TextView android:id="@+id/column_header1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
/>
<TextView android:id="@+id/column_header2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
/>
<TextView android:id="@+id/column_header3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
/>

</LinearLayout>

<ListView
android:id="@+id/booklist"
android:rotationY="180"
android:layout_width="match_parent"
android:layout_height="wrap_content" >



</ListView>


</LinearLayout>



TextView columnHeader1 = (TextView) findViewById(R.id.column_header1);
TextView columnHeader2 = (TextView) findViewById(R.id.column_header2);
TextView columnHeader3 = (TextView) findViewById(R.id.column_header3);


columnHeader1.setText("Id");
columnHeader2.setText("BookName");
columnHeader3.setText("Author");