Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在AppBarLayout下面添加空视图代替RecyclerView_Android_Android Recyclerview_Android Coordinatorlayout_Android Appbarlayout - Fatal编程技术网

Android 在AppBarLayout下面添加空视图代替RecyclerView

Android 在AppBarLayout下面添加空视图代替RecyclerView,android,android-recyclerview,android-coordinatorlayout,android-appbarlayout,Android,Android Recyclerview,Android Coordinatorlayout,Android Appbarlayout,在布局中添加自定义空视图代替recyclerview时,我遇到了一些问题。我的自定义空视图的重心为“中心垂直”。当我像这样添加它时,在自定义空视图中添加的图像和文本会隐藏在显示listview的区域下方。它正在脱离屏幕。我认为这是因为SwiperFreshLayout的“appbar_滚动_查看_行为”。但我确实需要这样做,以便appbar在列表滚动时滚动。但如果没有数据显示,我希望自定义空视图中的图像显示在屏幕中央appbarlayout的下方。目前它被推到屏幕底部 <?xml vers

在布局中添加自定义空视图代替recyclerview时,我遇到了一些问题。我的自定义空视图的重心为“中心垂直”。当我像这样添加它时,在自定义空视图中添加的图像和文本会隐藏在显示listview的区域下方。它正在脱离屏幕。我认为这是因为SwiperFreshLayout的“appbar_滚动_查看_行为”。但我确实需要这样做,以便appbar在列表滚动时滚动。但如果没有数据显示,我希望自定义空视图中的图像显示在屏幕中央appbarlayout的下方。目前它被推到屏幕底部

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

     <android.support.design.widget.AppBarLayout
      android:id="@+id/appBarLayout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content">

          <RelativeLayout
            android:id="@+id/headRelativeLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:focusableInTouchMode="true"
            app:layout_scrollFlags="scroll|enterAlways">

              <include
               android:id="@+id/topLayout"
               layout="@layout/top_sch_listview" />

              <include
                android:id="@+id/msgLayout"
                layout="@layout/view"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_below="@+id/topLayout" />

              <include
                android:id="@+id/subHeaderLayout"
                layout="@layout/view_sub_header"
                android:layout_width="match_parent"
                android:layout_height="@dimen/sub_header_height"
                android:layout_below="@+id/msgLayout" />

         </RelativeLayout>
   </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.SwipeRefreshLayout
      android:id="@+id/swipeRefreshLayout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:layout_behavior="@string/appbar_scrolling_view_behavior">

           <RelativeLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent">

                   <android.support.v7.widget.RecyclerView
                     android:id="@+id/recyclerListView"
                     android:layout_width="match_parent"
                     android:layout_height="match_parent" />

                     <com.my.views.CustomEmptyView
                      android:id="@+id/empty"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent" />
           </RelativeLayout>
   </android.support.v4.widget.SwipeRefreshLayout>

   <View
    android:id="@+id/blankView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:visibility="invisible" />

</android.support.design.widget.CoordinatorLayout>

我不确定我做错了什么。有人能帮忙吗


谢谢。

CustomEmptyView的删除

回收站列表视图 adpater中的两个观察孔设置

空视图支架>(自定义空视图)

DataView Holder>(RecycleView:列表)

数据数组计数检查

notifyDataSetChanged Previous

setType(标记,viewholder类中的类型值)


适配器notifyDataSetChanged()

我认为这行不通。它将以同样的方式运行。
public class AdvancedItemAdapter extends MultiItemAdapter {

public static final int VIEW_TYPE_EMPTY = 0;
public static final int VIEW_TYPE_DATA = 1;

@Override
public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    if (viewType == VIEW_TYPE_EMPTY) {
        EmptyViewHolder holder = (EmptyTYpeViewHolder)viewHolder;
        return holder;
    } else {
        DataViewHolder holder = (DataTYpeViewHolder)viewHolder;
        return holder;
    }

}
}