android-recyclerview

How to display multiple models on recycler view using same adapater?

岁酱吖の 提交于 2019-12-12 21:22:43
问题 I have two different types of objects (ex: User and Student) both having different properties. User: Title, description; Student: Title, description, USN; Is there a way using which I can display two users first and then students on the recycler view using same adapter? How do I display it even if it's two adapters. I dont' want two recycler views. Please note that the example given is very simple. The change is not just in UI. If the change is just in UI, then getItemViewType() can be used

RecyclerView: Race condition between notify* and scrollToPostion?

妖精的绣舞 提交于 2019-12-12 20:37:25
问题 Is is possible to have race conditions between the notify* methods of a RecyclerView.Adapter and scrollToPosition (and smoothScrollToPosition ) of the RecyclerView itself? If so, how can I force the scroll to happen strictly after the notify has been applied? In a bit more detail: I have a RecyclerView with an adapter that frequently is updated with new items (which may or may not overlap with the previous items). Also, whenever I set new items I also want to set the scroll position to a

Getting wrong position after Recyclerview filtering using SearchView

纵饮孤独 提交于 2019-12-12 20:35:16
问题 I trying to add a SearchView to my app using the website: http://www.tutorialsbuzz.com/2015/11/Android-Filter-RecyclerView-Using-SearchView-In-ToolBar.html Yet, I'm unable to send the user to the right Recyclerview position after clicking to the filtered result: For example : If a user searched for the 2nd result and he click it, the app will send him the next activity (details activity) using the 1st result instead for the 2nd result. Here are my app codes ( ListAdapter.java ): public class

android : generic recyclerview adapter with data binding

我的未来我决定 提交于 2019-12-12 20:29:27
问题 I have tried to create a generic Recyclerview adapter as below: BaseRecyclerAdapter: public class BaseRecyclerAdapter<T, MVH extends BaseViewHolder<T>, EVH extends BaseViewHolder<T>> extends RecyclerView.Adapter<BaseViewHolder<T>> { private static final int VIEW_TYPE_EMPTY = 0; private static final int VIEW_TYPE_DATA = 1; private List<T> list = new ArrayList<>(); @LayoutRes private int emptyViewLayoutResource; private Class<EVH> emptyViewHolder; @LayoutRes private int dataLayoutResource;

Android RecyclerView Blank Space

≯℡__Kan透↙ 提交于 2019-12-12 19:22:45
问题 I have an android project and I am using Recycler view to print a list with items, each item has just one image and between those images, android is creating a big blank space. I researched and saw about to change my layout to wrap_content and I changed it the recycler view layout, the itemlayout, the layout of the page but didn't work, I want to know what more options do I have to change, I will post here my 2 classes, the activity, and the adapter, and both layout XML and the item XML

How to keep Recyclerview items at same position?

社会主义新天地 提交于 2019-12-12 19:03:26
问题 I have the following issue. I populate a Recyclerview from my Fragment class. So far everything works out. However when I test my app and scroll up and down the populated recycler list the contents of each item change a.k.a. they get recycled... How can I save each item's position and restore its content to the same position after scrolling? Any suggestions? 回答1: Good Question, this is your answer holder.setIsRecyclable(false) . @Override public MyViewHolder onCreateViewHolder(ViewGroup

Implementing different layouts for RecyclerView but getting class cast erro on onBindViewHolder

梦想与她 提交于 2019-12-12 18:54:52
问题 I'm following this tutorial but I'm getting the following cast error: java.lang.ClassCastException: com.banshai.appetit.controllers.home.OpenRestaurantsViewHolder cannot be cast to com.banshai.appetit.controllers.home.FirstOpenRestaurantVHolder at com.banshai.appetit.controllers.home.RestaurantAdapter.onBindViewHolder The error is being called at onBindViewHolder when trying to cast: FirstOpenRestaurantVHolder firstVH = (FirstOpenRestaurantVHolder) viewholder; . What Am I missing? This is my

NoClassDefFoundError: android.support.v7.widget.helper.ItemTouchHelper$3

孤人 提交于 2019-12-12 18:34:39
问题 Hi I want to create swipe to delete on RecyclerView the result is a crash: Look at the build.gradle , I imported all the libs requeired. In code I'm able to use ItemTouchHelper class but when i want to swipe an item it crashes. build.gradle compile 'com.android.support:appcompat-v7:25.0.0' compile 'com.android.support:recyclerview-v7:25.0.0' compile 'com.android.support:cardview-v7:25.0.0' compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4' compile 'com.android.support

Scroll behaviour of AndroidX RecyclerView view with NestedScrollView

为君一笑 提交于 2019-12-12 18:22:29
问题 I'm migrating my application from appcompat to AndroidX. Everything works except that I am not able to set one scroll for both androidx.core.widget.NestedScrollView and androidx.recyclerview.widget.RecyclerView . I have tried adding setHasFixedSize(true) setNestedScrollingEnabled(false) but it's not working. My XML now looks this way: <?xml version="1.0" encoding="utf-8"?> <androidx.core.widget.NestedScrollView android:clipToPadding="false" android:id="@+id/scroll" android:layout_height="wrap

ListView recycling switches seekbar position

*爱你&永不变心* 提交于 2019-12-12 18:17:54
问题 I have a strange problem. I have a custom ListView with BaseAdapter . In my ListView row layout, I have few TextView s, Buttons , and a SeekBar . Everything works great, no problems with anything except with recycling. What happens: All SeekBar 's are hidden, except one which is visible. The SeekBar is visible when MediaPlayer on row is playing. That part is working great too. But, when user scrolls up or down, and the row with visible SeekBar is out of view, it recycles, and SeekBar is