android-recyclerview

How to set LayoutManager for RecyclerView in Android

家住魔仙堡 提交于 2020-01-02 08:11:31
问题 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(

how to know the previous and new positions?

喜夏-厌秋 提交于 2020-01-02 07:32:52
问题 I have a recyclerview with horizontal layout and only one view is visible at a time: mRecyclerView = findViewById(R.id.rvmain); mRecyclerView.setOnFlingListener(null); final SnapHelper snapHelper = new LinearSnapHelper(); snapHelper.attachToRecyclerView(mRecyclerView); mLayoutManager = new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new MainActivityRVAdapter(postsModels,MainActivity.this); mRecyclerView.setAdapter

How to achieve partially visible next item in RecyclerView

痞子三分冷 提交于 2020-01-02 07:16:10
问题 I'm using onFling to scroll one item at a time and want only one item to be fully visible on the page while next item to be visible partially. I want to this, how can I achieve this in RecyclerView. Here is the adapter code, just in place of cardView(which is shown in image), it's imageView: public class SimpleItemRecyclerViewAdapter extends RecyclerView.Adapter<SimpleItemRecyclerViewAdapter.ViewHolder> { private final ArrayList<Movie> mValues; public SimpleItemRecyclerViewAdapter(ArrayList

RecyclerView is not showing anything

时间秒杀一切 提交于 2020-01-02 07:03:51
问题 In my application I am getting data from sqlite database and showing them using RecyclerView. This is my adapter :- public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.Holder> { private List<SentData> dataList = Collections.emptyList(); private LayoutInflater inflater; public RecyclerViewAdapter(Context context, List<SentData> dataList) { Log.d("array size", dataList.size()+""); this.dataList = dataList; inflater = LayoutInflater.from(context); } @Override public

RecyclerView Lazy Loading (Universal Image Loader)

谁说胖子不能爱 提交于 2020-01-02 04:53:05
问题 Using Android Universal Image Loader and RecyclerView to asynchronously load images, I'm getting the same error as other people, where the images get mixed up; until they have all loaded an are cached. Code for the adapter: import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; import android.graphics.Bitmap; import android.media.Image; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view

RecyclerView generic adapter with DataBinding

大兔子大兔子 提交于 2020-01-02 04:37:07
问题 I have created generic adapter for RecyclerView by using DataBinding. Here is small code snippet public class RecyclerAdapter<T, VM extends ViewDataBinding> extends RecyclerView.Adapter<RecyclerAdapter.RecyclerViewHolder> { private final Context context; private ArrayList<T> items; private int layoutId; private RecyclerCallback<VM, T> bindingInterface; public RecyclerAdapter(Context context, ArrayList<T> items, int layoutId, RecyclerCallback<VM, T> bindingInterface) { this.items = items; this

Best place to attach onClickListener in recyclerview

对着背影说爱祢 提交于 2020-01-02 04:21:04
问题 While i was looking at some tutorials about recycler view.some of them used the viewHolder constructor to attach the onClick listener while some of them used the onBindViewHolder method. which method is the best place to attach the onclicklistener. i'm really confused 回答1: The method onBindViewHolder is called every time when you bind your view with data. So there is not the best place to set click listener. You don't have to set OnClickListener many times for the one View . So the best

Horizontal RecyclerView inside CoordinatorLayout

◇◆丶佛笑我妖孽 提交于 2020-01-02 03:42:13
问题 I'm new To Android development, I'm working with CoordinatorLayout in android lollipop device, The problem is I had a recyclerview with Horizontal scrolling to be collapsed on scrolling a recyclerview with vertical scrolling effect. It working good if I don't scroll the horizontal recyclerview, if I scrolled the horizontal scrollview once its not collapsing. My Code is activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res

RecyclerView IndexOutOfBoundsException

最后都变了- 提交于 2020-01-02 03:32:25
问题 Why exception execute when I removed some items in RecyclerView by using loop ? I used Collentions.synchronizedMap in adapter and 'deleteItem method' use synchronized too (the method in fragment). public void elementController(JsonObject jsonObject , String type) { if ( jsonObject == null || type == null ) { return; } int position =0 , resultPosition =0; if ( type.equals("update") || type.equals("delete")) { String id = jsonObject.get(ELEMENT_ID).getAsString(); Map<String , Element> map =

Loading image with glide is slow

落花浮王杯 提交于 2020-01-02 02:54:06
问题 I have app connect with server and when pics load seems so slow and when scroll that up and down seems glide want read image again! This is my adapter of glide: DataAdapter : public class DataAdapter extends RecyclerView.Adapter<DataAdapter.ViewHolder> { private Context context; private ArrayList<AndroidVersion> android; public DataAdapter(Context context,ArrayList<AndroidVersion> android) { this.context = context; this.android = android; } @Override public DataAdapter.ViewHolder