Tag: android recyclerview

删除RecyclerView滚动效果

我的导航抽屉里有两个RecyclerView。 两者都有蓝色滚动效果。 如何在两个RecyclerView中删除这个效果? 我试着改变这个:mRecyclerView.setHasFixedSize(true); 为虚假的,但没有改变(这种方法的效果是什么?) 链接到问题的图像 PD:对不起我的英文。

match_parent宽度在RecyclerView中不起作用

我的RecyclerView和项目具有match_parent宽度,但结果是: <view class="android.support.v7.widget.RecyclerView" android:layout_width="match_parent" 和项目: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/apk/res-auto" android:id="@+id/ll_itm" android:orientation="horizontal" android:layout_width="match_parent" 充分: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/apk/res-auto" android:id="@+id/ll_itm" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:weightSum="100" android:gravity="right" > <Button android:layout_width="0dp" android:layout_weight="15" android:layout_height="fill_parent" android:text="ملاحظات" android:id="@+id/button" /> <LinearLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="20" android:gravity="center" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <com.getbase.floatingactionbutton.FloatingActionButton android:layout_width="fill_parent" android:layout_height="fill_parent" fab:fab_plusIconColor="#ff56ff83" fab:fab_colorNormal="@color/d_red" fab:fab_colorPressed="#ff5c86ff" fab:fab_size="mini" fab:fab_icon="@drawable/ic_remove_white" android:id="@+id/fab_rmv" /> […]

RecyclerView中检测到不一致,如何在滚动时更改RecyclerView的内容

我正在使用RecyclerView来显示项目的名称。 我的行包含单个TextView 。 项目名称存储在List<String> mItemList 。 要更改RecyclerView内容,我将replacemItemListstring,并在RecyclerViewAdapter上调用notifyDataSetChanged ()。 但是,如果我试图改变mItemList内容,而RecyclerView正在滚动,有时它会给我java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 157(offset:157).state:588 java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 157(offset:157).state:588 如果mItemList大小比以前小, mItemList发生这种情况。 那么改变RecyclerView内容的正确方法是什么? 这是RecyclerView的错误吗? 这里是例外的完整堆栈跟踪: java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 157(offset:157).state:588 at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3300) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3258) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1803) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1302) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1265) at android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1093) at android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:956) at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:2715) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725) at android.view.Choreographer.doCallbacks(Choreographer.java:555) at […]

显示单个项目的回收站视图

我正面临一个奇怪的错误,其中recyclerview只显示一个项目。 以下是我的recyclerview适配器的代码: public class ChatAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { List<chat> chats; String username; final int My=0,Their=1; public ChatAdapter(List<chat> chats) { this.chats = chats; this.username = PushApp.getApp().getSPF().getStringData(Constants.ANAME); } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { RecyclerView.ViewHolder viewHolder; LayoutInflater inflater = LayoutInflater.from(parent.getContext()); switch (viewType) { case My: View v1 = inflater.inflate(R.layout.my_chat_child, parent, false); viewHolder = new MyChatHolder(v1); […]

RecyclerView丢失

我刚刚安装了新的SDK工具(Android L Developer Preview),我试图使用RecyclerView但它似乎缺less。 从我的理解,我应该包括v7支持库,但我似乎无法做到这一点… 我似乎无法findSDK文件夹中的V7库(我没有从SDKpipe理器安装Android支持库)。 谢谢你。

以编程方式向recyclerview添加一个新项目?

我仍然试图让我的头靠近recyclerview。 我有一个arraylist,我用来初始化回收站视图。 如何将新项目添加到回收站查看post中设置适配器和layoutmanager? private void initData() { mItems = new ArrayList<String>(); for (int i = 0; i < ITEMS_COUNT; i++) { mItems.add("Item " + (i + 1)); } } private void initRecyclerView() { mRecentRecyclerView = (RecyclerView) findViewById(R.id.recentrecyclerView); mRecentRecyclerView.setHasFixedSize(true); mRecentLayoutManager = new LinearLayoutManager(this); mRecentRecyclerView.setLayoutManager(mRecentLayoutManager); mAdapter = new RecyclerView.Adapter<CustomViewHolder>() { @Override public CustomViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) […]

RecyclerView内嵌滚动视图滚动,但不像正常的Recyclerview或嵌套滚动视图快速滚动

我在NestedScrollView内使用RecyclerView ,它的工作原理。 但是当我在LinearLayout使用RecyclerView时,它会根据手势以各种速度滚动。 滚动听手势,如果我只滑动了一下,那么它会滚动一点点,而如果我真的很快滑动,那么它滚动真的很快。 现在我的问题是, NestedScrollView里面的NestedScrollView肯定滚动,但快速滚动不起作用。 但是,我滑快或慢, RecyclerView或NestedScrollView只滚动一点点。 我怎样才能使我的NestedScrollView或RecyclerView内滚动视图滚动不同速度?

RecyclerView上的Android setOnScrollListner已弃用

setOnScrollListener已弃用。 从这里读取文档告诉使用addOnScrollListener(OnScrollListener)和removeOnScrollListener(OnScrollListener) 。 什么是add and remove OnScrollListener的正确方法? 我是否需要在onPause使用removeOnScrollListner ,并使用onResume addOnScrollListener再次设置它?

如何从XML设置RecyclerView应用程序:layoutManager =“”?

如何从XML设置RecyclerView layoutManager? <android.support.v7.widget.RecyclerView app:layoutManager="???" android:layout_width="match_parent" android:layout_height="match_parent"/>

使用RecyclerView适配器更新数据的最佳方法

当我不得不使用一个经典的适配器与ListView ,我更新我的数据在这样的ListView: myAdapter.swapArray(data); public swapArray(List<Data> data) { clear(); addAll(data); notifyDataSetChanged(); } 我想知道什么是RecyclerView的最佳做法。 因为在RecyclerView适配器中,您不能像ListView中那样执行clear和addAll 。 所以我尝试了一个notifyDataSetChanged ,但它没有工作。 然后我试着用我的视图swapAdapter: List<Data> data = newData; MyRecyclerAdapter adapter = new MyRecyclerAdapter(data); // swapAdapter on my recyclerView (instead of a .setAdapter like with a classic listView). recyclerViewList.swapAdapter(adapter, false); 但是通过这个最后的解决scheme,我仍然需要创build一个新的适配器实例,我觉得这不是最好的解决scheme。 我应该能够更改我的数据,而不需要新的MyRecyclerAdapter 。