我有一个列表视图,它是活动的一部分。我希望用户可以选择批量删除列表视图中的项目,因此当他从菜单中选择相应的选项时,每个列表项旁边都会有一个复选框。当用户单击任何复选框时,按钮栏将从底部向上滑动(如在 gmail 应用程序中)并单击删除按钮删除所选项目,但是单击栏上的取消按钮将取消选中所有选中的项目。
这是我的页面 layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent"
>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="@+id/list_area"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
>
<ListView
android:id="@+id/mylist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:drawSelectorOnTop="false"
android:layout_weight="1"
/>
<TextView
android:id="@+id/empty_list_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_gravity="center_vertical|center_horizontal"
android:text="@string/msg_for_emptyschd"
android:layout_margin="14dip"
android:layout_weight="1"
/>
</LinearLayout>
<RelativeLayout
android:id="@+id/bottom_action_bar"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/schedule_bottom_actionbar_border"
android:layout_marginBottom="2dip"
android:layout_gravity="bottom"
android:visibility="gone"
>
<Button
android:id="@+id/delete_selecteditems_button"
android:text="Deleted Selected"
android:layout_width="140dip"
android:layout_height="40dip"
android:layout_alignParentLeft="true"
android:layout_marginLeft="3dip"
android:layout_marginTop="3dip"
/>
<Button
android:id="@+id/cancel_button"
android:text="Cancel"
android:layout_width="140dip"
android:layout_height="40dip"
android:layout_alignParentRight="true"
android:layout_marginRight="3dip"
android:layout_marginTop="3dip"
/>
</RelativeLayout>
</FrameLayout>
</LinearLayout>
到目前为止,我已经完成了所有工作,除了当底部栏在复选框选择时变得可见时,它与列表的最后一个元素重叠。所有其他列表项都可以向上滚动,但您不能向上滚动列表的最后一项,因此如果用户愿意,则不能选择该项目。这是重叠的屏幕截图。
我曾尝试使用 listview 页脚选项,但这会将栏附加到列表的末尾,而不是将其固定在屏幕底部。有没有办法我可以“提高”列表视图足以使重叠不会发生?顺便说一句,我已经尝试将底部边距添加到列表视图本身,或者在使按钮栏可见之前包装列表视图的线性布局,但它引入了其他错误,例如单击一个复选框会检查列表视图中的另一个复选框。