android-recyclerview

Fragments as a RecyclerView's ViewHolder?

爷,独闯天下 提交于 2020-01-03 03:12:09
问题 How would one go about creating a RecyclerView who's ViewHolder children are actually Fragments? current example (does not work, views are stacked on top of eachother) Here is the onResume() for a Fragment which is the main content of an Activity // onResume() in FragmentA (main content of an Activity) recyclerView.addItemDecoration(new VerticalSpaceItemDecoration(5)); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false); List

RecyclerView LinearLayoutManager set item count

巧了我就是萌 提交于 2020-01-03 02:40:09
问题 In GridLayoutManager i am able to set span count and that makes the items inside the view to resize to be able to fit that span count horizontally. I have a LinearLayoutManager and i want to use it the same way, have a fixed number of items visible and resize them to fit. I use both linear and grid on same view and shows items depending of the screen size. I can't seem to find a way to get both layouts showing the same amount of items. 回答1: UPDATED My previous answer was to use ItemsAdapter

RecyclerView LinearLayoutManager set item count

走远了吗. 提交于 2020-01-03 02:40:04
问题 In GridLayoutManager i am able to set span count and that makes the items inside the view to resize to be able to fit that span count horizontally. I have a LinearLayoutManager and i want to use it the same way, have a fixed number of items visible and resize them to fit. I use both linear and grid on same view and shows items depending of the screen size. I can't seem to find a way to get both layouts showing the same amount of items. 回答1: UPDATED My previous answer was to use ItemsAdapter

How to change selected item position to top in Recyclerview?

我只是一个虾纸丫 提交于 2020-01-03 01:46:13
问题 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? 回答1: 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! 回答2: Try this String Item = List.get(position); List.remove(position); // remove

Downloading Image in Recyclerview

白昼怎懂夜的黑 提交于 2020-01-02 20:12:02
问题 I have a recycler view which has an Imageview in the Viewholder. The Image is downloaded via AsyncTask in the onBindViewHolder in the adapter. The problem is when I scroll down or up, the onBindViewHolder is called for recycling the view holder and the Images are downloaded again and again. Now I understand that this is how Recyclerview is supposed to work. So can anyone tell me if anything can be done to avoid downloading the Images more than once. Or will it be better to move back to

Downloading Image in Recyclerview

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-02 20:11:14
问题 I have a recycler view which has an Imageview in the Viewholder. The Image is downloaded via AsyncTask in the onBindViewHolder in the adapter. The problem is when I scroll down or up, the onBindViewHolder is called for recycling the view holder and the Images are downloaded again and again. Now I understand that this is how Recyclerview is supposed to work. So can anyone tell me if anything can be done to avoid downloading the Images more than once. Or will it be better to move back to

Update text within card view list?

筅森魡賤 提交于 2020-01-02 18:23:13
问题 So I have a recyclerview list of card views.I am trying to update the text time text in each view when the user clicks the card, and then reset it back when time has past. I set up an internal method in recyclerviewadapter but when I call updateTimes (calling from fragment), it does not reset the text back. Can someone instruct me on what I'm doing wrong? import java.util.ArrayList; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.net.Uri; import android

java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true when scrolling down

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 08:24:34
问题 FATAL EXCEPTION: main Process: com.zipato.android.client.v2, PID: 24966 java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true at android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:5736) at android.support.v7.widget.RecyclerView$Recycler.recycleView(RecyclerView.java:5680) at android.support.v7.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:289) at android.support.v7.widget

Android RecyclerView adding pagination

ⅰ亾dé卋堺 提交于 2020-01-02 08:17:15
问题 I created a RecyclerView for my application and trying to find a way to stop huge requests, I want to get the results 10 by 10 with a progress bar. My server will send the results 10 by 10 on every scrolldown to last item. public class ProfileActivityFriendsList extends AppCompatActivity { String[] names={"Ander Herera","David De Gea","Michael Carrick","Juan Mata","Diego Costa","Oscar"}; String[] positions={"Midfielder","GoalKeeper", "Midfielder","Playmaker","Striker","Playmaker"}; String[]

How to set LayoutManager for RecyclerView in Android

人走茶凉 提交于 2020-01-02 08:11:46
问题 In my application I want show some RecyclerViews . I want show 3 item in one row , I my application should use 4 recyclerView because each recyclerVews each data other API . In one of RecyclerView I can show 3 Item in one row, and I should show another 3 recyclerViews above of this RecyclerView . Please see this image to understand my mean : I write below code in Java : if (movieResponse.getData().getStars().size() > 0) { starsModel.clear(); starsModel.addAll(movieResponse.getData().getStars(