Tag: recyclerview

removing RecyclerView items

I have a RecyclerView which is adding items each certain period. When adding objects, if list items are more than (lets say) 500, then the first items will be removed and the new items will be added. If the RecyclerView cannot scroll down any more !recyclerView.canScrollVertically(1); then, after adding new items the RecyclerView will smoothScroolToPosition() […]

Android RecyclerView last item remove (runtime) error

I have RecyclerView with custom list item and with CardView item, in two different Activities. Now i am getting error when i remove last remained item from list, i did not change any code related to those acitivities or adapter or RecyclerView. Error is: java.lang.NullPointerException at android.support.v7.widget.OrientationHelper$2.getDecoratedStart(OrientationHelper.java:316) at android.support.v7.widget.LinearLayoutManager.findOneVisibleChild(LinearLayoutManager.java:1633) at android.support.v7.widget.LinearLayoutManager.findFirstVisibleChildClosestToStart(LinearLayoutManager.java:1453) at android.support.v7.widget.LinearLayoutManager.computeScrollOffset(LinearLayoutManager.java:997) at android.support.v7.widget.LinearLayoutManager.computeVerticalScrollOffset(LinearLayoutManager.java:969) […]

Android Data Binding : Observable List to RecyclerView's Adapter

Is their a way, by using the ObservableList class from the new Data Binding library and the MVVM pattern, to avoid using “notifyItem(s)…” methods from the Adapter class? Or if not what could be the simpliest way to bind an ObservableList to a RecyclerView? Thank’s for any clue !

How to force PopupMenu to overlap anchor?

How to force PopupMenu to overlap anchor? I would like to recreate something similar to this:

LayoutManager for RecyclerView Grid with different cell width

StaggeredGridLayoutManager doesn’t seem to allow customising a cell width or span multiple columns (except full span) for vertical orientation. What is a preferred LayoutManager for organising cells as shown above? P.S. I just want to know how to customise cell width and not height with StaggeredGridLayoutManager. I know height can be customised as implemented in […]

How to handle click-event in RecyclerView.ItemDecoration?

I have a RecyclerView (with LinearLayoutManager) and a custom RecyclerView.ItemDecoration for it. Let’s say, I want to have buttons in the decoration view (for some reason..). I inflate the layout with button, it draws properly. But I can’t make the button clickable. If I press on it, nothing happening(it stays the same, no pressing effect) […]

Android – how to change Recyclerview height dynamically?

I’m stuck with an issue about changing Recycler height based on its total items. What I have tried is to use Layout Param like this: ViewGroup.LayoutParams params = myRecyclerView.getLayoutParams(); params.height = itemHeight * numberOfItem; myRecyclerView.requestLayout(); or ViewGroup.LayoutParams params = new RecyclerView.LayoutParams(..WRAP_CONTENT, …WRAP_CONTENT);; params.height = itemHeight * numberOfItem; myRecyclerView..setLayoutParams(params); But it didn’t work. How can I […]

Abrupt scrolling with NestedScrollView in ViewPager Fragment inside a CoordinatorLayout Android

I am facing a major scrolling problem with ViewPager inside CoordinatorLayout. The current scene: app:appbarScrollingViewBehaviour is set on ViewPager. The ViewPager fragment has NestedScrollView as its root parent. The fragment layout contains Horizontal RecyclerView. When I scroll up by touching over RecyclerView, the app bar doesn’t scroll, instead only nested scrolling occurs. When I scroll […]

Where should I unbind ButterKnife 8.x.x in a ViewHolder?

I have a RecycleView.ViewHolder class which use ButterKnife annotations. Should my code unbind() in this ViewHolder class too? public class AView extends RecyclerView.ViewHolder { @BindView(R.id.a_text_view) TextView aText; public AView(final View view) { super(view); ButterKnife.bind(this, view); // It returns an Unbinder, but where should I call its unbind()? } } The docs (http://jakewharton.github.io/butterknife/) does not talk […]

How to save scroll position of RecyclerView in Android?

I have Recycler view which lays inside of SwipeRefreshLayout. Also, have ability to open each item in another activity. After returning back to Recycler I need scroll to chosen item, or to previous Y. How to do that? Yes, I googled, found articles in StackOverFlow about saving instance of layout manager, like this one: RecyclerView […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.