android-recyclerview

RecyclerView scrolls to top position when change the adapter data

风格不统一 提交于 2020-01-04 01:24:28
问题 I am doing the like and dislike for a post in a RecyclerView , I call the api after changing the view but the problem is that the RecyclerView always scrolls to the top when I notify it with the updates. this is my adapter code : likeAnim.setOnLikeListener(object : OnLikeListener { override fun liked(p0: LikeButton?) { if (commentList[position]!!.liked) { // likeButton.setBackgroundResource(R.drawable.heart_ico) isLiked = false callback(commentList[position], 2, layoutPosition) } else { //

Saving state custom RecyclerView

蹲街弑〆低调 提交于 2020-01-03 19:23:56
问题 I made a custom RecyclerView in order to enable pagination in the lists of my application. I'm having a crash at restoring state. Maybe this crash is related to a known bug in the support library, but, teorically, it has been resolved in support library version 24.0.0 : https://code.google.com/p/android/issues/detail?id=196430, but it is still crashing. Maybe I'm doing something wrong? I'm having a BadParcelableException ClassNotFoundException when unmarshalling: android.support.v7.widget

Scroll RecyclerView up accordingly when keyboard opens

扶醉桌前 提交于 2020-01-03 17:30:30
问题 I have created a chat activity and like facebook messenger, there is an EditText at the bottom and above is the RecyclerView of messages. When Keyboard opens, I want to scroll RecyclerView up exactly how much it should scroll up. To be more specific, lets assume there are 5 messages in the RecyclerView and currently 3rd message is just above the EditText. So when keyboard is open, I want to keep 3rd message just above the EditText like before. I have searched but could not find. If this is a

How to cycle through items in Android RecyclerView?

时间秒杀一切 提交于 2020-01-03 17:13:41
问题 How can you cycle through the items in an Android RecyclerView? I would like to have a RecyclerView that scrolls horizontally. When the end is reached to the right, it simply continues scrolling by restarting the list of items. the same to the left. For example: List of items: 0,1,2,3,4,5,6,7,8,9 Starting view shows: 0,1,2,3,4,5,6,7 After scrolling 5 items to the right: 5,6,7,8,9,0,1,2 After scrolling 2 items to the left: 8,9,0,1,2,3,4,5 回答1: another idea would be, getItemCount() of your

How to cycle through items in Android RecyclerView?

a 夏天 提交于 2020-01-03 17:13:14
问题 How can you cycle through the items in an Android RecyclerView? I would like to have a RecyclerView that scrolls horizontally. When the end is reached to the right, it simply continues scrolling by restarting the list of items. the same to the left. For example: List of items: 0,1,2,3,4,5,6,7,8,9 Starting view shows: 0,1,2,3,4,5,6,7 After scrolling 5 items to the right: 5,6,7,8,9,0,1,2 After scrolling 2 items to the left: 8,9,0,1,2,3,4,5 回答1: another idea would be, getItemCount() of your

Using a single RecyclerView.Adapter for multiple RecyclerViews

浪尽此生 提交于 2020-01-03 16:54:47
问题 What I've done: I have a viewpager with 4 fragments which inflate the same layout containing a RecyclerView. I've built a single Adapter for all of the fragments. When I click an item it loads data and appends the data to a List and set the new data to the adapter. Problem: the problem is when I change the data of particular recyclerview of a particular fragment the changes take effect on all the recyclerviews. 来源: https://stackoverflow.com/questions/28472702/using-a-single-recyclerview

Images disappear when scrolling up and down and spaces increase between images using Glide and RecyclerView

爷,独闯天下 提交于 2020-01-03 16:00:35
问题 I have a RecyclerView to display my images and I use Glide to load images from their URLs from my database in Firebase Storage. The problem is, when I scroll up and down, images reload and sometimes disappear and spaces between each image increase. How can I stop this? My RecyclerViewAdapter @Override public myViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View row = LayoutInflater.from(parent.getContext()).inflate(R.layout.image_layout,parent,false); myViewHolder

Images disappear when scrolling up and down and spaces increase between images using Glide and RecyclerView

*爱你&永不变心* 提交于 2020-01-03 15:59:00
问题 I have a RecyclerView to display my images and I use Glide to load images from their URLs from my database in Firebase Storage. The problem is, when I scroll up and down, images reload and sometimes disappear and spaces between each image increase. How can I stop this? My RecyclerViewAdapter @Override public myViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View row = LayoutInflater.from(parent.getContext()).inflate(R.layout.image_layout,parent,false); myViewHolder

How to have a ContextMenu when the recyclerview item is set onLongClickListener

倾然丶 夕夏残阳落幕 提交于 2020-01-03 15:50:11
问题 How can I have a context menu inside the RecyclerViewAdapter when the view is set onLongClickListener? Here is my code: public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView name; public ViewHolder(View itemLayoutView) { super(itemLayoutView); name = (TextView) itemLayoutView.findViewById(R.id.rvname); itemLayoutView.setOnClickListener(this); itemLayoutView.setOnLongClickListener(new View.OnLongClickListener() { @Override public

Callback on notifyiteminserted / notifyitemremoved / notifyitemmoved

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-03 15:36:54
问题 Looking for something really simple. I looked around in the source code for RecyclerView but couldn't find anything for this. Before I start implementing my own version, I wanted to know if someone knows of anyway to receive a callback on the animation for notifyiteminserted , notifyitemremoved , notifyitemmoved ? This is important because I want to know when the animation has completed. 来源: https://stackoverflow.com/questions/34350970/callback-on-notifyiteminserted-notifyitemremoved