相关疑难解决方法(0)

是否有与RecyclerView相同的addHeaderView?

我正在为回收者视图寻找相当于addHeaderView的东西.基本上我想要一个带有2个按钮的图像作为标题添加到列表视图中.是否有不同的方法将标题视图添加到回收站视图?指导的一个例子会很有帮助

编辑2(添加片段布局):

添加日志语句后,似乎getViewType只接收到0的位置.这导致onCreateView只加载一个布局:

10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? …
Run Code Online (Sandbox Code Playgroud)

android android-view android-recyclerview

279
推荐指数
10
解决办法
19万
查看次数

我希望我的RecyclerView不回收一些物品

我在RecyclerView内部使用异构视图,如本教程中所示.

我在RecyclerView里面有一些物品也是RecyclerViews.难以想象?假设我要复制Play商店的布局:一个具有垂直线性布局的大型RecyclerView,并由许多元素填充:单个应用程序和应用程序轮播.

如果要添加的项目是单个应用程序的布局,则将使用ID 1,我将添加单个项目的布局.另外,如果我需要添加一个Carousel,那么我将在主RecyclerView中添加一个元素:另一个带有自己的适配器的RecyclerView.

这非常有效.滚动主RecyclerView时除外.为什么?因为某些视图在不再可见时被销毁,然后在onBindViewHolder()方法中重新创建.为什么在这?因为主RecyclerView的适配器正在传递位置X然后调用OnBindViewHolder().然后,后者使用自己的适配器创建一个新的RecyclerView并将其分配给它.我想保留这些观点只是因为它们每次重新充气都很重要.

这可能吗?如果是的话,你能告诉我怎么样吗?

android android-layout android-recyclerview

28
推荐指数
5
解决办法
3万
查看次数

如何使RecyclerView停止回收定义的位置?

我的问题是:我在RecyclerView内的其中一个视图上发生了视频流.

当用户滚动时,视图将被回收,其他摄像头会在该回收的视图持有者上开始自己的流式传输.这对用户界面不利,因为流式处理需要几秒钟才能启动.

我怎么能对RecyclerView说:"嘿嘿回收器,请不要回收那个确切的位置x并给出那个位置总是与你第一次给出的相同的观察者,而不是随机的一个"?

请有人帮帮我=(

android recycle android-layout android-viewholder android-recyclerview

19
推荐指数
3
解决办法
2万
查看次数

scrollview内的Recyclerview-如何滚动整个内容?

我在Scrollview中有Recyclerview

 <Scrollview
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

    <LinearLayout
        android:id="@+id/layoutStaticContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

       //Static content.
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="100dp">
           .
           .
        <LinearLayout>

         //Dynamic content(newsfeed)
         <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>
 </ScrollView>
Run Code Online (Sandbox Code Playgroud)

现在,在滚动时,layoutStaticContent在顶部保持修复,并在底部独立滚动回收内容.如何滚动整个内容即(layoutStaticContent + recyclerview内容),这样只有1个scrollview?我也尝试用Nestedscrollview替换scrollview但没有成功.

android android-recyclerview nestedscrollview

9
推荐指数
2
解决办法
6439
查看次数

滚动到全视图与里面的回收者视图

我想建立一个屏幕,我在顶部和下面有一个布局,我有一个像这样的回收站视图:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    tools:context="com.app.InstHomeDir.Fragments.PendingDocument"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/main_bg"
   >

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:layout_marginBottom="15dp"
        >

    <android.support.v7.widget.CardView

        android:background="@color/white"
        app:cardElevation="2dp"
        app:cardCornerRadius="2dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <com.app.InstHomeDir.Util.Roboto_Edit_Text_Bold
             android:textColor="@color/bl2d2d2d"
             android:padding="5dp"
            android:text="DOCUMENT LIST"
                android:textSize="20sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
            <com.app.InstHomeDir.Util.Roboto_EditText
             android:padding="5dp"
             android:textColor="#6f6f6f"
            android:layout_marginTop="5dp"
            android:layout_width="wrap_content"
                android:textSize="12sp"
            android:text="@string/Pending_Doc"
            android:layout_height="wrap_content"/>
        </LinearLayout>


    </android.support.v7.widget.CardView>


    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_penddoc"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_anchor="@id/toolbar_layout"
        app:layout_anchorGravity="bottom|center"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        >

    </android.support.v7.widget.RecyclerView>


    </LinearLayout>



</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

现在我想给整个视图滚动视图,但是当我这样做时,屏幕的滚动并不顺畅,因为屏幕上有两个滚动,我该如何解决这个问题?谁能帮我?

android android-scrollview android-recyclerview

7
推荐指数
1
解决办法
5577
查看次数