Tag: recyclerview

How to retain ViewPager state inside a RecyclerView?

My RecyclerView contains many ViewPagers. The number of pages inside each ViewPager is constant (2). I use PagerAdapter. When I scroll my RecyclerView, the ViewPagers lose their state and reset to the 1st page. I want to know how to retain the last selected page for each ViewPager. For example: 1) I scroll to page […]

RecyclerView scrollbar jumps back to top after first item

I created a very basic RecyclerView example. Layout: <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent” tools:context=”.MyActivity”> <android.support.v7.widget.RecyclerView xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/recyclerView” android:layout_width=”match_parent” android:layout_height=”match_parent” android:scrollbars=”vertical”/> </RelativeLayout> Activity: public class MyActivity extends Activity { RecyclerView mRecyclerView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); mRecyclerView.setAdapter(new TestAdapter()); mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); } public static class TestAdapter extends RecyclerView.Adapter<TestAdapter.ViewHolder> { @Override […]

GridLayoutManager spanSizeLookup bug

I am having an issue with GridLayoutManger setSpanSizeLookup, when an orientation of activity changes, I am changing the span count while checking if the specific position is some sort of type, this works perfectly on orientation change, my only problem is, I’m using zxing library to do barcode scanning, whenever a button is clicked I’m […]

Handle touch event for items inside Recyclerview – android

i’m building a simple recyclerview with custom layout (Text view and switch) and a custom adapter. My problem is i can’t handle the click event for the switch (Which make it toggle its state), i have built a touch listener for the recyclerview and it fires every time i click on the Switch. After a […]

Does RecyclerView.ViewHolder always have to be an inner class?

I have two RecyclerView.Adapters that are using exactly the same RecyclerView.ViewHolders as inner classes. I wanted to get rid of code duplication and made these ViewHolders free, separate class so the brand new class now can be used by any RecyclerView.Adapters. However I faced lots of troubles for example difficulty in accessing the adapter objects. […]

YouTubePlayerFragment inside ReyclerView

I have a RecyclerView with CardViews inside it. I want each CardView to have its own YouTubePlayerFragment. Even if they can’t all be active at once, I can’t even seem to instantiate the YouTubePlayerFragment in any CardView but the first in the RecyclerView. When clicking the button on the card that’s supposed to set up […]

RecyclerView not scrolling to the bottom

I followed the recyclerview guidelines and built one for the app I am making, but it does not scroll to the bottom for some reason. I compared it with google code snippets, as well as other code snippets online and can’t see the difference. I have posted a picture and the code I am using. […]

RecyclerView findViewHolder null for off-screen items

[first time asker and first time android coder so I apologize if I do something wrong] I’m trying to change the value inside of an itemview on my recycler. However, if that itemview happens to be offscreen, the findViewBy[layout,adapter,or id] comes up null. public void setUserActive(UserListAdapter adapter, RecyclerView recyclerView, int position, View v) {recyclerView.findViewHolderForItemId(adapter.getItemId(position)); TextView […]

Google play store like interface using recycler view

My assignment is to create an interface much same like Google Play Store.There will a Category name followed by 3 or 4 cards (horizontal) followed by More button. Then again next category. I already had implemented this using nesting the horizontal listview inside Vertical listview. I know, I can achieve this by using the Recycler […]

How to handle a lot of different view types in recyclerview viewholder

What if I have 50 types of views? Should I have 50 static inner classes in my adapter? According to this answer, yes. My first thought was to move each viewholder inner class into a seperate public class, but they have to be static. So encapsulate each one into a public class, to make the […]

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