2013-03-26 1 views
1

listviews внутри scrollview, показывающий только один элемент списка? как отобразить все элементы списка

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 
    <TextView 
     android:id="@+id/section_one_header" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="18dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginTop="10dp" 
     android:singleLine="true" 
     android:text="Summary" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textColor="#51556C" 
     android:textSize="13sp" 
     android:textStyle="bold" /> 

    <ListView 
     android:id="@+id/section_list_view" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginTop="5dp" > 
    </ListView> 

    <TextView 
     android:id="@+id/section_two_header" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="18dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginTop="10dp" 
     android:singleLine="true" 
     android:text="Data" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textColor="#51556C" 
     android:textSize="13sp" 
     android:textStyle="bold" > 
    </TextView> 

    <LinearLayout 
     android:id="@+id/eve_det" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginTop="5dp" 
     android:background="@layout/style_evedetail" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/section_two_data" 
      android:layout_width="fill_parent" 
      android:layout_height="100dp" 
      android:layout_marginBottom="10dp" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginTop="10dp" 
      android:scrollbars="vertical" 
      android:textSize="10sp" > 
     </TextView> 

     <EditText 
      android:id="@+id/section_two_edit_text" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="10dp" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginTop="10dp" 
      android:focusableInTouchMode="true" 
      android:imeActionId="@+id/done_button" 
      android:imeActionLabel="done" 
      android:singleLine="true" /> 
    </LinearLayout> 

    <TextView 
     android:id="@+id/section_three_header" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="18dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginTop="10dp" 
     android:text="Attachment" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textColor="#51556C" 
     android:textSize="13sp" 
     android:textStyle="bold" > 
    </TextView> 
    <ListView 
     android:id="@+id/attachment_list_view" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="20dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" /> 
</LinearLayout> 

это код под видом прокрутки. Здесь мне нужно отобразить заголовок и соответствующий ListView, затем TextView с помощью Edit Text, затем снова заголовок и ListView. Может ли кто-нибудь помочь мне, как показать все элементы списка в двух списках, или если кто-нибудь другой может мне помочь.

+0

выписки следующему постом для информации http://stackoverflow.com/questions/6210895/listview-inside -scrollview-is-not-scrolling-on-android –

ответ

1

Да, поскольку представление списка имеет функцию прокрутки по умолчанию, имеющую функцию прокрутки. Если вы разместите представление списка внутри другого просматриваемого прокрутки (скажем, прокрутки). Прокрутка списка будет затруднять.

Чтобы избежать такой вещи, в представлении списка есть понятия заголовка и нижнего колонтитула.

Вы можете добавить n количество верхних и нижних колонтитулов в список.

Ниже приведен пример фрагмента кода, как добавить заголовок/колонтитул раздувания любого макета XML ему

LayoutInflater inflater = activity.getLayoutInflater(); 
LinearLayout listFooterView = (LinearLayout)inflater.inflate(
      R.layout.footer_layout, null); 

list.addFooterView(listFooterView); 


LinearLayout listHeaderView = (LinearLayout)inflater.inflate(
       R.layout.header_layout, null); 

    list.addHeaderView(listHeaderView); 
+0

Спасибо за ваше предложение, это так полезно. Iam способен просматривать заголовок Textview, но я не могу просмотреть все элементы списка «section_list_view», «attachment_list_view», они показывают только один элемент. –

+0

Вам нужно полностью удалить вид прокрутки, просто используйте list-view вместе с нижними колонтитулами и заголовками и не забудьте дать некоторую высоту двум отдельным спискам просмотров –

Смежные вопросы