recycler-adapter

RecyclerView updates only on scroll

不羁岁月 提交于 2019-12-10 12:39:11
问题 I have a layout with a RecyclerView with the adapter: public class SimpleRecyclerAdapter extends RecyclerView.Adapter<SimpleViewHolder> { protected List<JSONObject> data = new ArrayList<>(); public List<JSONObject> getData() { return data; } } I update it's adapter like: public void udpdateFromJson( JSONObject payload ) { JSONArray msgs = payload.optJSONArray( "messages" ); for( int ix = 0; null != msgs && ix < msgs.length(); ix++ ){ JSONObject o = msgs.optJSONObject( ix ); if( loadingMore )

Recycler View inside another Parent Recycler View

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 11:47:53
问题 Is it possible that I can use a recycler view inside another recycler view ? My requirements are to show multiple Lists in a screen : Vertical List of 3 Items Horizontal List of 10 Items Vertical List of 5 Expandable Items Again Horizontal List of 5 Items So, I was thinking to have a MultiRecylerAdapter, which would hold adapters for other recyler views inside. 回答1: I found the solution. We can insert the recycler view ( either vertical or horizontal) inside any other recyclerview but default

Calling notifyItemChanged() on a RecyclerView.Adapter from another class

北城以北 提交于 2019-12-10 09:56:49
问题 I have a RecyclerView in AdapterActivity . After clicking on any of its items, I update that item using my AlertDialogShow#UpdateStudent() method. My problem is that I can not refresh the Adapter inside the UpdateStudent() method using notifyItemChanged() . How can I refresh the Adapter from another class that does not have direct access to the Adapter ? In the AdapterActivity with the RecyclerView : holder.itemView.setOnLongClickListener(new View.OnLongClickListener() { @Override public

Lags when RecyclerView scrolling

最后都变了- 提交于 2019-12-10 06:26:28
问题 I can not understand what is the reason the brakes when you scroll through my RecyclerView. Scrolling is called by mRecyclerView.smoothScrollToPosition(position); When you scroll through the list of twitches (rendering time frame> 16ms) AlphaAdapter.java public class AlphaAdapter extends RecyclerView.Adapter<AlphaAdapter.ViewHolder> { private static final String TAG = "AlphaAdapter"; private Context mContext; private List<PrimaryWeapon> mGunList; private boolean isAnimate; private final int

RecyclerView disappearing images

♀尐吖头ヾ 提交于 2019-12-09 16:42:53
问题 What I am trying to create is a horizontal scrolling image gallery. I have a RecyclerView (support 22.0.0). The problem I am having is that when I scroll to the end and then scroll back, usually one image will be missing sometimes two. Strangely when I keep swiping back and forth, a different image could be missing. Here is the layout for the item: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="160dp">

RecyclerView corrupts view using notifyItemMoved()

左心房为你撑大大i 提交于 2019-12-09 10:34:21
问题 I'm having a problem with using the notifyItemMoved() method. It seems to be incorrectly displaying unmoved views. My list has 4 element in it. What I want to do is animate a swap between item 1 and item 3. Items 1 and 3 swap correctly, but item 2 displays what was at item 3! So the list starts off looking something like this: Item 0 Item 1 Item 2 Item 3 And ends like this: Item 0 Item 3 Item 3 <!-- What the heck has this changed for? Item 1 My adapter is backed by a List mProductList . I

What is the difference between swapadapter method and notifydatasetchanged method in Recycler view?

时光毁灭记忆、已成空白 提交于 2019-12-08 15:57:57
问题 I would like to know what exactly is the difference between swapAdapter and notifyDatasetChanged methods of RecylerView? Which one is better to use while modifying the data? 回答1: As the Documentation reads. public void swapAdapter (Adapter adapter, boolean removeAndRecycleExistingViews) Swaps the current adapter with the provided one. It is similar to setAdapter(Adapter) but assumes existing adapter and the new adapter uses the same RecyclerView.ViewHolder and does not clear the

Regarding ProperScrolling in Horizontal Recycler View

橙三吉。 提交于 2019-12-08 15:51:45
问题 I have issues scrolling in horizontal recycler view.For eg if i have 10 items,very first time,I am able to scroll till last item,But if i go to first item and then scroll again to last item,it is not moving to last item. Is this issue related to scrolling,Should i override for scrolling,if that's case. This is my fragment class declaration LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false); mRecyclerView = (RecyclerView)v.

How to change selected item position to top in Recyclerview?

百般思念 提交于 2019-12-08 14:03:28
I have recyclerview in that I want to change item's position dynamically to top after selecting the item of recyclerview . Please suggest best way to achieve the above problem? You need to swap selected item with top item in list, then notify your adapter about position change. A sample code would look like: Collections.swap(orderItems.getItems(), position, 0); notifyItemMoved(position, 0); Hope it helps! Try this String Item = List.get(position); List.remove(position); // remove item from the list List.add(0,removedItem); // add at 0 index of your list notifyDataSetChanged();

How implement multi view types for RecycleView?

坚强是说给别人听的谎言 提交于 2019-12-08 12:46:20
问题 Currently, I work on custom multi-view types for RecycleView. I found many solutions for this problem, but I will share my way. The different is use enum for define ViewType. See my answer for more detail. (Just want to share). 回答1: UPDATE I recommend read this article: Writing Better Adapter Here is the way I custom multi-view types for RecyclewView. I will show the code first, then explain bellow. @SuppressWarnings("unchecked") public class BaseAdapter extends RecyclerView.Adapter