I have issues scrolling in horizontal recycler view.For eg if i have 10 items,very first time,I am able to scroll till last item,But if i go to first item and then scroll again to last item,it is not moving to last item.
Is this issue related to scrolling,Should i override for scrolling,if that's case.
This is my fragment class declaration
LinearLayoutManager layoutManager
= new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
mRecyclerView = (RecyclerView)v. findViewById(R.id.recycler_view);
adapter = new MyRecyclerAdapter(getActivity());
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setAdapter(adapter);
and in my adapter
public class MyRecyclerAdapter extends RecyclerView.Adapter<MyRecyclerAdapter.CustomViewHolder> {
private Context mContext;
JobSiteActivity mjobSiteActivity;
ImageLoader loader = null;
public MyRecyclerAdapter(Activity activity) {
this.mContext = activity;
mjobSiteActivity = (JobSiteActivity)activity;
loader = mjobSiteActivity.getImageLoader();
}
@Override
public CustomViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.image_detail_fragment, null);
CustomViewHolder viewHolder = new CustomViewHolder(view);
return viewHolder;
}
@Override
public void onBindViewHolder(CustomViewHolder customViewHolder, int i) {
//FeedItem feedItem = feedItemList.get(i);
//Download image using picasso library
/* Picasso.with(mContext).load(feedItem.getThumbnail())
.error(R.drawable.placeholder)
.placeholder(R.drawable.placeholder)
.into(customViewHolder.imageView);*/
customViewHolder.imageView.setImageUrl(Images.imageThumbUrls[i], loader);
customViewHolder.imageView.setOnClickListener(clickListener);
customViewHolder.imageView.setTag(customViewHolder);
//Setting text view title
}
@Override
public int getItemCount() {
//return (null != feedItemList ? feedItemList.size() : 0);
return Images.imageThumbUrls.length;
}
public class CustomViewHolder extends RecyclerView.ViewHolder {
protected NetworkImageView imageView;
public CustomViewHolder(View view) {
super(view);
this.imageView = (NetworkImageView) view.findViewById(R.id.imageView);
}
}
View.OnClickListener clickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
CustomViewHolder holder = (CustomViewHolder) view.getTag();
int position = holder.getLayoutPosition();
int position1 = holder.getAdapterPosition();
Toast.makeText(mContext, "layoutPs"+position+"adapPos"+position, Toast.LENGTH_SHORT).show();
}
};
}
I am trying to use horizontal Grid view which comes with V17 leanback which also extends recycleView,but Still I am also facing similar sort of issue,
If i try to add any item to recycler view at runtime for eg on taking Photo,it is also not getting added,It allocates space and it is empty?Very hard to understand or debug on this issue.
This example will show you how to add and update RecyclerView items when horizontal scroll it. When the user scrolls from left to right at the beginning of RecyclerView, it will add a new item at the beginning. When the user scrolls from right to left at the end of RecyclerView, it will insert another new item at the ending.
When user scroll from left to right at the beginning of RecyclerView, it will add a new item at beginning. When user scroll from right to left at the end of RecyclerView, it will insert another new item at the ending.
How to Create Dynamic Horizontal RecyclerView in Android using Firebase Firestore? HorizontalRecyclerView is seen in many apps. It is generally used to display the categories in most apps and websites. This type of RecyclerView is seen in many E-commerce apps to indicate categories in the app.
I have a fragment layout that is a part of a PageViewer. The fragment has 2 RecyclerViews - one on the top of the layout which is horizontal, the other one at the bottom which is vertical.
Try to use layoutManager like this, may help you
LinearLayoutManager layoutManager=new LinearLayoutManager(getApplicationContext(),LinearLayoutManager.HORIZONTAL,false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With