我有一个非常简单的recyclerview具有以下布局: -如何删除在Android的回收站视图中删除项目后剩下的空白空间?
<LinearLayout
android:id="@+id/address_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<include layout="@layout/address_recyclerview"></include>
</LinearLayout>
Wher我回收视图布局如下: -
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/adr_recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
/>
这是我使用从删除的项目代码回收站观点: -
private void removeItem(UserInfo list) {
int current_position = listData.indexOf(list);
listData.remove(current_position);
notifyItemRemoved(current_position);
}
我的线性布局是一种滚动View.Now内,当我删除回收站内的项目来查看该项目被删除BU t删除后留下空白空间。当回收站视图内的项目被删除时,如何自动删除此空间?
任何帮助或建议表示赞赏。谢谢。
调试并检查删除项目后列表大小是否减1。 也试试notifyDataSetChanged() – Mrinmoy