listview - Android - creating LinearLayout with non-static number of fields (TextView) -
i have create layout 7 elements every of elements have variable numbers of items. that:
<scrollview 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="com.example.lessons"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5dp" android:orientation="vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5dp" android:orientation="vertical"> <textview android:id="@+id/lessons_text_1" android:layout_width="match_parent" android:layout_height="wrap_content"/> <listview android:id="@+id/lessons_list_1" android:layout_width="match_parent" android:layout_height="match_parent"/> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical"> <textview android:id="@+id/lessons_text_2" android:layout_width="match_parent" android:layout_height="wrap_content"/> <listview android:id="@+id/lessons_list_2" android:layout_width="match_parent" android:layout_height="match_parent"/> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:orientation="vertical"> <textview android:id="@+id/lessons_text_3" android:layout_width="match_parent" android:layout_height="wrap_content"/> <listview android:id="@+id/lessons_list_3" android:layout_width="match_parent" android:layout_height="wrap_content"/> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:orientation="vertical"> <textview android:id="@+id/lessons_text_4" android:layout_width="match_parent" android:layout_height="wrap_content"/> <listview android:id="@+id/lessons_list_4" android:layout_width="match_parent" android:layout_height="wrap_content"/> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:orientation="vertical"> <textview android:id="@+id/lessons_text_5" android:layout_width="match_parent" android:layout_height="wrap_content"/> <listview android:id="@+id/lessons_list_5" android:layout_width="match_parent" android:layout_height="wrap_content"/> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:orientation="vertical"> <textview android:id="@+id/lessons_text_6" android:layout_width="match_parent" android:layout_height="wrap_content"/> <listview android:id="@+id/lessons_list_6" android:layout_width="match_parent" android:layout_height="wrap_content"/> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:orientation="vertical"> <textview android:id="@+id/lessons_text_7" android:layout_width="match_parent" android:layout_height="wrap_content"/> <listview android:id="@+id/lessons_list_7" android:layout_width="match_parent" android:layout_height="wrap_content"/> </linearlayout> </linearlayout>
but can't put listview in scrollview. when create linearlayout 1 textview , try clone it, there still 1 element. how it?
the best way have listview contain both:
void addfooterview(view v)
add fixed view appear @ bottom of list.
void addheaderview(view v)
add fixed view appear @ top of list.
take @ documentation @ http://developer.android.com/reference/android/widget/listview.html