android-recyclerview

DiffUtil ItemCallback areContentsTheSame() always returns true after updating an item on the ListAdapter

本小妞迷上赌 提交于 2020-02-21 13:49:51
问题 While using a ListAdapter I noticed that after updating an item the DiffUtil.ItemCallback areContentsTheSame() method was always returning true. Debugging the code I realized that the old and the new item were exactly the same (the old state disappeared). Therefore the ListAdapter onBindViewHolder() method wasn't being called to update the respective row on the list (only the order of the items changed with a nice animation). Checking other questions on Stackoverflow looks like it's a common

Firebase android how to prevent FirebaseRecyclerAdapter automatically updating?

旧街凉风 提交于 2020-02-20 08:53:42
问题 I have a FirebaseRecyclerAdapter which I do not want to keep updating the RecyclerView . This is because I have it so it populates the view with items based on how many 'views' they have in the database. The problem is, if other people view the items, the list you see in the app will keep changing order. Is there a way to stop the recycler adapter from constantly listening for data changes or will I have to go about this another way? Any help is greatly appreciated, thanks. 回答1: The adapters

Firebase android how to prevent FirebaseRecyclerAdapter automatically updating?

谁都会走 提交于 2020-02-20 08:52:05
问题 I have a FirebaseRecyclerAdapter which I do not want to keep updating the RecyclerView . This is because I have it so it populates the view with items based on how many 'views' they have in the database. The problem is, if other people view the items, the list you see in the app will keep changing order. Is there a way to stop the recycler adapter from constantly listening for data changes or will I have to go about this another way? Any help is greatly appreciated, thanks. 回答1: The adapters

How to stop Incessant crash on search filter in Android recyclerview

∥☆過路亽.° 提交于 2020-02-09 17:20:29
问题 I have been struggling to stop an index out of bounds exception crash every single time I do a search in a searchview. I tried a couple of things listed online : on search getting array out of index bound exception https://www.codeproject.com/Questions/1040119/Android-app-is-crashing-with-Index-out-of-range-is but nothing helped so far. The issue is something specific to my code, just can't figure out what's the issue. Here's my crash report: E/AndroidRuntime: FATAL EXCEPTION: main Process:

How to put serialize and get serializeContext in Kotlin Android?

巧了我就是萌 提交于 2020-02-08 10:06:33
问题 I want save and keep my state in fragment because when tap on recyclerView items and back to fragment with listener i lost my Context and my context in fragment is null . So i try to keep my context like this: override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) outState.putSerializable("SaveContext", context) } 回答1: You should initialize your context correctly. Check below as for example class MyFragment: Fragment() { private var mContext: Context? = null

Clicking CardView to load a fragment

孤人 提交于 2020-02-08 01:33:08
问题 I'm having trouble with implementing clickable cards with my RecyclerView. I want to get the position of which card was clicked and then load the proper fragment. I did take a look at this post and spent almost 30 minutes trying to make sense of the code and implementing it myself but I gave up when I realized how many mistakes were in the snippet. Here is my adapter class. public class RVAdapter extends RecyclerView.Adapter<RVAdapter.PersonViewHolder> { public static CardView cv; public

Clicking CardView to load a fragment

懵懂的女人 提交于 2020-02-08 01:30:14
问题 I'm having trouble with implementing clickable cards with my RecyclerView. I want to get the position of which card was clicked and then load the proper fragment. I did take a look at this post and spent almost 30 minutes trying to make sense of the code and implementing it myself but I gave up when I realized how many mistakes were in the snippet. Here is my adapter class. public class RVAdapter extends RecyclerView.Adapter<RVAdapter.PersonViewHolder> { public static CardView cv; public

RecyclerView item onClick not working while being updated rapidly

柔情痞子 提交于 2020-02-06 08:44:46
问题 I bet it's a trivial mistake. But here I sit, wasting hours on it: I have a simple app that scans for Bluetooth devices and shows the discovered devices' information in cards in a RecyclerView (one card per device). Clicking on one of the CardViews initiates the connection to the respective device. That works fine after the scan has stopped (after some seconds) and the cards aren't bound to new data anymore. During the scan however, only few of the touches onto the cards are recognized. I'm

How to refresh the Recycler View on TextView change

谁说胖子不能爱 提交于 2020-02-06 07:26:24
问题 I have a Recycler View list. I want to refesh the Recycler View on TextView value change 回答1: Did you try? : textMessage = (EditText)findViewById(R.id.textMessage); textMessage.addTextChangedListener(new TextWatcher(){ public void afterTextChanged(Editable s) { //Refresh your view, make network calls to server or something } }); 来源: https://stackoverflow.com/questions/29419660/how-to-refresh-the-recycler-view-on-textview-change

Multiple layers of shadows in android recyclerview elevation

筅森魡賤 提交于 2020-02-06 04:16:49
问题 I have a recyclerview with an elevation of 8dp, transparent background and bounds as outlineProvider. clipToPadding is set to false on the parent relativelayout. I am facing a weird issue w.r.t the shadow cast by the recyclerview elevation. The shadow seems to cover up the edges of the recyclerview or there is an extra layer between the relativelayout and the child recyclerview (Attached an image reference). What is actually causing this effect? I have searched a lot but could not find any