<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>
这是 ScrollView 下的代码。这里我需要显示标题和相应的ListView,然后显示带有编辑文本的TextView,然后再次显示标题和ListView。任何人都可以帮助我如何在两个 ListView 中显示所有列表项,或者如果任何人有其他想法帮助我。
最佳答案
是的,因为 ListView 具有默认的可滚动功能。如果将 ListView 放置在另一个可 ScrollView 中(例如 Scroll-view )。列表滚动将会受到阻碍。
为了避免这种情况, ListView 具有页眉和页脚 View 的概念。
您可以向列表中添加 n 个页眉和页脚。
下面是一个示例代码 fragment ,如何通过向其扩展任何 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);
关于android - ScrollView 内的 ListView 仅显示一个列表项?如何显示所有列表项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15635987/