Tag: recyclerview

RecyclerView recalculate WRAP_CONTENT

With version 23.2 we can now use WRAP_CONTENT for recyclerView height, which is great. I am doing this, however I want to recalculate the height after an item is added (or removed) to the adapter (thus increasing or decreasing the height). My particular RecyclerView is starting with 1 item, and then adding items as the […]

RecyclerView grid with different item sizes

I need to create a horizontal scrolling grid that can allocate items with different width and different height. StaggeredGridLayoutManager can handle different width but it won’t let me have items with different height. Is there any LayoutManager implementation which can do what I need?

RecyclerView with custom shaped items

I created a custom shaped imageview. It works fine if you use it in scrollview. But when i tried to use it in a recyclerview there’s a strange behavior i observed. Images are not getting draw and show gap (see 1st image) unless you scroll down (see 2nd image). Same thing happens when you scroll […]

How to use ButterKnife OnItemClick with RecyclerView?

As onItemClick is no more in RecyclerView, does ButterKnife still able to handle its item clicks with @onItemClick or with @onClick annotations? If not so, any work around to use that?

Centering items in a RecyclerView when it's implemented with GridLayoutManager

I have a RecyclerView implemented using the GridLayoutManager. Depending on how many items are in the data set, the spanCount is between 1-4. The item widths change depending on the spanCount. If the spancount is 4 or above, the spanCount is left at 4. If I have 5 items, this leaves 1 item left over […]

Replace ListView with RecyclerView

How can I replace old Listview with Recylerview? What changes should I keep in mind when replacing Listview with Recyclerview?

setLayoutManager NullPointException in RecyclerView

I’m trying to receive a list with an array in RecyclerView and get error: java.lang.NullPointerException: Attempt to invoke virtual method ‘void android.support.v7.widget.RecyclerView.setLayoutManager (android.support.v7.widget.RecyclerView$LayoutManager)’on a null object reference RecyclerView widget’s <android.support.v7.widget.RecyclerView android:id=”@+id/drawerList” android:layout_width=”match_parent” android:layout_height=”wrap_content”> </android.support.v7.widget.RecyclerView> I tried to declare LayoutManager to final, but it doesn’t help. Activity code: public class MainActivity extends ActionBarActivity { private RecyclerView […]

RecyclerView overlapping without shadow

I want to develop List like this picture I had used to RecylerView ItemDecorator for overlap. But it’s overlapping without shadow. the screen & decorator code is below public class OverlapDecoration extends RecyclerView.ItemDecoration { private final static int vertOverlap = -50; @Override public void getItemOffsets (Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { outRect.set(0, […]

Android sticky header RecyclerView/ Section Header RecyclerView

Hello All I have just created a demo to work with new android L widget RecyclerView.I have also implemented Pull-To-Refresh using SwipeRefreshLayout but problem for me now is how can I implement sticky header here,Because when i try to set mRecyclerView.setOnScrollListener(new OnScrollListener() { @Override public void onScrolled(int arg0, int arg1) { } @Override public void […]

How open fragment from RecyclerView.Adapter<CardAdapter.ViewHolder>

1.TabLayout – tab1 (Fragment1) – tab2 (Fragment2) – tab3 (Fragment3) * RecyclerView + CardView (OnClick) On CardView ClickListner open another fragment in tab3. So how to open fragment in tab3. Error is in getFragmentManager(): FragmentTransaction transaction = getFragmentManager().beginTransaction(); Instead of this, I tried: FragmentTransaction transaction = activity.getFragmentManager().beginTransaction(); FragmentTransaction transaction = itemview.getContext().getFragmentManager().beginTransaction(); But error is not […]

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