recycler-adapter

Recyclerview on Scrolling values changing from adapter

蓝咒 提交于 2019-11-27 21:23:56
I am working on an app where I am trying to populate a list using RecyclerView and recycler adapter as well. But when I scroll through the list quickly sometimes values on the list item shuffles among list items. Is there a known fix for this? adding this in the adapter solved the problem @Override public int getItemViewType(int position) { return position; } Just Override these methods in your adapter class: @Override public long getItemId(int position) { return position; } @Override public int getItemViewType(int position) { return position; } This link will help you to get the understanding

RecyclerView adapter taking wrong values

陌路散爱 提交于 2019-11-27 21:09:59
问题 I have a RecyclerView wich shows two kinds of View s one represents an User publication and another that represents an Event publication. Both have elements in common, for example a TextView that shows a time stamp. So I created a PublicationViewHolder that takes this TextView time stamp into a variable and load it. My issue is that the adapter, initially, load the right values, but when I scroll down, and scroll up again, the values in the positions are changed by values from another

Recyclerview Adapter and Glide - same image every 4-5 rows

前提是你 提交于 2019-11-27 18:30:40
I have this problem - just for testing purposes I added ParseFile to one of ParseObject from received list. Instead of showing it only in that row it shows every 4-5 rows, sometimes more, sometimes less. I supspect that recycling view have something to do with this. Strangely, other data (deleted from this example) works fine with position variable. @Override public void onBindViewHolder(ViewHolder holder, int position) { if(parseList.get(position).get("logo") != null){ ParseFile image = (ParseFile) parseList.get(position).get("logo"); String url = image.getUrl(); Glide.with(context) .load(url

RecyclerVIew auto scroll to display all the elements as in News Feed etc.,

霸气de小男生 提交于 2019-11-27 15:26:26
问题 How to auto scroll RecyclerView smoothly so that user can see all the elements of the RecyclerView and scroll again from the start - as in News Feed etc. I know smoothScrollToPosition() and scrollToPosition() but they would just end up scrolling too fast to the last element. I want the RecyclerView to be animated and move slowly. 回答1: Just to improve on the answer a little, it's auto scrolling infinity with smooth animation. final int speedScroll = 1200; final Handler handler = new Handler();

Lint error “Do not treat position as fixed; only use immediately…”

元气小坏坏 提交于 2019-11-27 15:04:15
I'm contributing to open source library and got lint error "Do not treat position as fixed; only use immediately and call holder.getAdapterPosition() to look it up later" for this code: @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { mAdapter.onBindViewHolder(holder, position); if (!isFirstOnly || position > mLastPosition) { for (Animator anim : getAnimators(holder.itemView)) { anim.setDuration(mDuration).start(); anim.setInterpolator(mInterpolator); } mLastPosition = position; } else { ViewHelper.clear(holder.itemView); } } I've checked that it is

StaggeredGridLayoutManager and moving items

荒凉一梦 提交于 2019-11-27 11:23:05
I have created a very simple project, displaying 28 images with StaggeredGridLayoutManager by recyclerview. but as I scroll the recyclerview it moves items for example from left to right or swap the column of left and right. codes: import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.os.Bundle; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.StaggeredGridLayoutManager; public class MainActivity extends Activity { String mImageDir; private RecyclerView mRecyclerView; private StaggeredGridLayoutManager mLayoutManager;

How to update/refresh specific item in RecyclerView

北城余情 提交于 2019-11-27 11:04:15
I'm trying to refresh specific item in RecyclerView . Story: Whenever user clicks on item, it shows AlertDialog . User can type some text by clicking ok button. I want to show this text in this item and show invisible ImageView - declared in XML and adapter ViewHolder - I used this function in AlertDialog Positive Button to update the item: private void updateListItem(int position) { View view = layoutManager.findViewByPosition(position); ImageView medicineSelected = (ImageView) view.findViewById(R.id.medicine_selected); medicineSelected.setVisibility(View.VISIBLE); TextView orderQuantity =

Equivalent of ListView.setEmptyView in RecyclerView

最后都变了- 提交于 2019-11-27 10:07:51
In RecyclerView , I want to set an empty view to be shown when the adapter is empty. Is there an equivalent of ListView.setEmptyView() ? With the new data binding feature you can also achieve this in your layout directly: <TextView android:text="No data to display." android:visibility="@{dataset.size() > 0 ? View.GONE : View.VISIBLE}" /> In that case you just need to add a variable and an import to the data section of your XML: <data> <import type="android.view.View"/> <variable name="dataset" type="java.util.List<java.lang.String>" /> </data> Here's a class similar to @dragon born's, but more

kotlin recyclerview data not showing

。_饼干妹妹 提交于 2019-11-27 09:54:23
Our question is how to show Parent and Child data from two SQLite DB tables? We have two tables that are added to two ArrayLists childList and parentList . Here are the Model Class's for each class ModelParent { var idD:Int = 0 var dept:String = "" var fkD:Int = 0 var children: List<ModelChild> = mutableListOf() //var children: ArrayList<ModelChild>? = null //var children: List<ModelChild> by Delegates.notNull() constructor (children: List<ModelParent>) : this() companion object { var globalVar = 1 } } class ModelChild { var idI:Int = 0 var item:String = "" var fkI:Int = 0 } We have two

Data is getting added into list instead of getting updated in addChildEventListener's onChildChanged()

大憨熊 提交于 2019-11-27 08:42:22
问题 I have some data in firebase which gets changed on some specific actions and I want that change to be shown in the app. I have a RecyclerView in which all the data from firebase is getting populated. Here's code: databaseReference.child("uListings").child(AccessToken.getCurrentAccessToken().getUserId()).addChildEventListener(new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String s) { // recyclerview gets populated here } @Override public void