FAQ Database Discussion Community


RecyclerView's OnScrollListener is an abstract class?

java,android,oop,recyclerview
What is the benefit of making RecyclerView.OnScrollListener an abstract class? Now you actually have to create a separate class instead of simply implementing the listener's method in the Fragment/Activity... This question was asked before here but the answer just quotes Google which doesn't seem to really answer what benefits there...

Android Create a Custom RecyclerView.Adapter and Create Other Cass from it

java,android,recyclerview
Well people I have a RecyclerView wich I populate from a WebService, and I have a DataProvider class that manage the async requests. So when the data is fetched I need this DataProvider to inform the RecyclerView.Adapter that there is new data. For this I need to add a method...

What LayoutManager should I use for a RecyclerView to avoid distributing cards evenly?

android,recyclerview
tl;dr: What do I need to do to get the result from the first image instead of the second one (concerning the blue squares)? First, the code snippets are at https://gist.github.com/exhuma/125ec8a5e32b395fd786 and an image for reference, representing the intended outcome: I have an application with 3 RecyclerViews. One "main" list...

RecyclerView Mixing Up Items

android,recyclerview
I have a RecyclerView that displays a list of images and text that are downloaded from the internet via a RecyclerView adapter. The problem arises when I scroll up and down the RecyclerView. As I scroll down the list initially, everything seems fine and all the CardViews (a cardview containing...

Vertical scroll the RecyclerView in Android by pixels

android,recyclerview
In my chat app I use RecyclerView and LayoutManager for showing chat messages list. I have a case when user browse old messages and new message arrives. At that point I want to scroll chat by small distance to acknowledge user of received new message. I need to scroll my...

RecyclerView wrap_content with GridLayoutManager

android,recyclerview,gridlayoutmanager
I've seen workarounds with LinearLayoutManager, but not with GridLayoutManager. Any ideas?

Disable Swipe for position in RecyclerView using ItemTouchHelper.SimpleCallback

android,recyclerview
I am using recyclerview 22.2.0 and the helper class ItemTouchHelper.SimpleCallback to enable swipe-to-dismiss option to my list. But as I have a type of header on it, I need to disable the swipe behavior for the first position of the adapter. As RecyclerView.Adapter doesn't have a isEnabled() method, I tried...

RecycleView's span size

android,recyclerview,gridlayoutmanager
I'm trying to achieve a layout similar to the picture above with the RecyclerView in conjunction with the GridLayoutManager, i tried setting the setSpanSizeLookup based on position but couldn't mimic the design above.. anyone could help please? mRecyclerView = (RecyclerView) contentView; mRecyclerView.setHasFixedSize(false); GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 3); gridLayoutManager.setSpanSizeLookup(new...

Adding items to Endless Scroll RecyclerView with ProgressBar at bottom

android,recyclerview,infinite-scroll,android-recyclerview
I followed Vilen's excellent answer on SO: Put an indeterminate progressbar as footer in a RecyclerView grid on how to implement an endless scroll recyclerview with ProgressBar. I implemented it myself and it works but I would like to extend the example. I want to add extra items at the...

RecyclerView data are multiple modified/displayed

android,adapter,onclicklistener,recyclerview,android-viewholder
I've a small problem with my RecyclerView. It's well filled by my adapter with some TextViews, an ImageView and some buttons. When there's an OnClick-Event on one of the buttons it modifies a TextView - so far so good but when I'm scrolling some items further another RecyclerView-item is also...

Android reverse shared element transition on back after orientation change?

android,material-design,recyclerview,onbackpressed,shared-element-transition
For shared element transition I am following this github project. It has 2 screens - one with recyclerview having number of cards & second the detail screen. As expected, it exhibits shared element transition of imageview & textview from recyclerview item to detail screen & reverse transition on back press....

PopupMenu is not positioned properly inside RecyclerView

java,android,imageview,recyclerview,popupmenu
I'm making an Android app to load data into a RecyclerView with an ImageView inside as the overflow button. When users click it, a PopupMenu is displayed with options to choose. I had managed to show it but the position does not seem right. Please look at the screenshots. Only...

Dividers didn't display in RecyclerView after addItemDecoration() called

android,recyclerview
A RecyclerView is nested in a CardView. I tried to call addItemDecoration() to add dividers into RecycylerView, but it didn't work. <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" card_view:cardBackgroundColor="@color/white_color" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" card_view:cardElevation="3dp"> <android.support.v4.widget.SwipeRefreshLayout...

Clicking CardView to load a fragment

android,android-fragments,recyclerview,android-cardview
I'm having trouble with implementing clickable cards with my RecyclerView. I want to get the position of which card was clicked and then load the proper fragment. I did take a look at this post and spent almost 30 minutes trying to make sense of the code and implementing it...

Remove all items from RecyclerView

android,adapter,recyclerview
I am trying to remove all the elements from my RecyclerView in my onRestart method so the items don't get loaded twice: @Override protected void onRestart() { super.onRestart(); //first clear the recycler view so items are not populated twice for(int i=0; i<recyclerAdapter.getSize(); i++) { recyclerAdapter.delete(i); } //then reload the data...

How to get RecyclerView to view a certain position WITHOUT scrolling?

java,android,recyclerview
I'm currently working with a RecyclerView with a custom manager (found here if interested). I want to be able to change where the RecyclerView is currently "looking" (ie what position(s) are being displayed). The problem is that when I need to do this, I don't want the user to see...

How to add swipelayout in recyclerview inside viewpager fragment?

android,android-viewpager,recyclerview,swipeview
I'm using AndroidSwipeLayout for 'Swipe To Delete' Action in RecyclerView Item. Swipe is not working as parent of RecyclerView is ViewPager Fragment. SwipeLayout also contain parent.requestDisallowInterceptTouchEvent(true); to intercept touchEvent from parent. What is the solution for this without disabling ViewPager swipe.

SlidingPaneLayout items in RecyclerView

java,android,listview,recyclerview,slidingpanelayout
I'm populating a RecyclerView with several SlidingPaneLayout items, as to achieve a 'swipe to delete' functionality (basically, dragging an item to the right reveals a DELETE button) Problem: When I drag an item to the right, it seems like the RecyclerView also intercepts my touches, and if my drag is...

how to highlight the selected Item of Recycler View?

android,material-design,recyclerview
I have a Recycler View with the Images loaded from the Internal Storage. I want to Highlight the selected item when clicked. I tried a lot of thing but it was not working. Actually what I need is when I click any item in Recycler View that Item must go...

Getting position of View in onCreateViewHolder

java,android,android-view,recyclerview,android-viewholder
I am using a RecyclerView with a single row layout with an ImageView and a TextView. I want to implement a OnClickListener for the View and not for seperate ViewHolder objects. How can i get the position of the view in the Adapter? Right now i'm deleting comments on click,...

CoordinatorLayout layout_anchor does not work

android,recyclerview,android-design-library,coordinator-layout
I just tried out the new Support Design Library with CoordinatorLayout, but I'm having problems anchoring child views. My layout currently looks like this: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinator_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar"...

Android CardView setBackground as BitmapDrawable when API <21

android,bitmap,recyclerview
I have a problem when I am trying to setBackground() of a CardView programatically in KitKat.When the application is running on Android L there is no problem in my code : Drawable drawable = new BitmapDrawable(appContext.getResources(), bitmap); if (cardView != null) { cardView.setBackground(drawable); } But when it runs in API...

alignment issue with RecyclerView in android 4.4

android,xml,layout,recyclerview
I am implementing a RecyclerView in my application and it is working. But i am facing a problem with the list item alignment in Recyclerview. actually my list item have a image view and a text view. i need some space between the each list item. like this With this...

Android - How to stop images reloading in Recyclerview when scrolling

android,recyclerview
I was creating an app for loading images from internet in cards. I am using Recyclerview for listing purpose. For downloading images, I have tried Picasso, universal-image-downloader and other custom methods but everywhere I have this problem: Whenever I scroll down and up the images in imageview are getting reloaded....

How to get other views in same ViewHolder at same position as the onClicked view (use in a RecyclerView Adapter)

android,onclick,recyclerview
I have a RecyclerView in my app that displays a row containing pictures and photographs downloaded from the internet. There is a photo and a button on screen. When the user clicks a button, I want to make another view visible on top of the on screen photo. I have...

Cardslib's CardRecyclerView is always null

android,android-layout,recyclerview,android-cardview,cardslib
I am developing with cardslib library and implementing this example. Although I slavishly follow the instructions in the tutorial when I create a CardRecyclerView object, that object appears to always be null. Check my code: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.native_recyclerview_card_layout); ArrayList<Card> cards = new ArrayList<Card>(); //Create a...

Is there any simple implementation or tutorial to implement RecyclerView in android?

android,recyclerview
I am trying to port my existing project to material design but am unable to understand the implementation of RecyclerView. My old code uses a ListView but I want GMail app like lists. I have read tons of tutorials but most of them either skip the ItemDecoration part or the...

Some data not set by RECYCLER ADATER

android,adapter,recyclerview
This is my on createView. I see in the log cat that all the data is available but some of the data is not set in the adapter. The balance card is not a part of the recycler view. This is done in a fragment. When the oncreate view of...

change data in recyclerview

android,recyclerview
Seems like I still can't get hold of how notifydatasetchanged works. I tried to update a variable in adapter, but couldn't do it successfully. I tried like below, also tried to define separate class Nav Drawer items, but just couldn't do anything. Basically, the count should be updated time to...

Gradle not using latest version of the support library?

android,android-studio,gradle,android-support-library,recyclerview
I've been using the android.support.v7.widget package -- specifically the RecyclerView class (among others but this is where the problem is). It was working fine until earlier today it randomly seems to default to an earlier version of the package now. I say that because: When I try calling myRecyclerView.addOnScrollListener(myScrollListener), myRecyclerView.getChildAdapterPosition(myView)...

Android RecyclerView select first Item

android,selection,recyclerview,highlighting
I'm using a RecyclerView to implement a NavigationDrawer. I got click events working, but I can't figure out how to have the first item selected on App start and following that keep the selected item higlighted even if the drawer is not shown. All I've been able to find is...

RecylerView with a fixed first row as header

android,recyclerview
I would like to create a recycler view with a fixed first row, which should act as the header. Also ,how can I prevent it from scrolling with other row elements ?

RecyclerView.itemDecoration onDraw c.drawLine incompatible with pre-lollipop devices?

android,recyclerview
I'm trying to create my own CustomDivider class which extends to RecyclerView. ItemDecoration based on the samples from Google which had a divider. Fortunately the code I tried works but I've only tried it in an emulator that runs in Lollipop and I found that it doesn't work in my...

Why do I load more than once when implementing load more data on the bottom of recyclerview?

android,recyclerview
I implement the following code. It works, but I retrieve it more tha once, it makes many duplication in my data. How do I make it to run the retrieve more data just once? final LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager(); recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() { boolean loading = true; @Override public void...

Recyclerview - smoothScrollToPosition to Top of list and then animate the addition of item

android,adapter,recyclerview,smooth-scrolling
I'm trying to create a Recyclerview that will scroll to the top first and then animate the addition of an item onto the recyclerview. This is the code I have so far: while (!mLayoutManager.isSmoothScrolling()) { mRecyclerView.smoothScrollToPosition(0); } PostList.add(0, post); mAdapter.notifyItemInserted(0); mAdapter.notifyItemRangeChanged(1, PostList.size()); This does scrolls to the top but the...

Saving State of a ToggleButton in a RecyclerView in android

java,android,recyclerview
I have a recyclerView that gets data from a url that outputs json and loads a image using picasso and some other datas. Each item in the view has a image, name, date and a ToggleButton. I implemented a setOnCheckedChangeListener for the toggle button to add the images that are...

RecyclerView onItemClicked callback

android,onclick,onclicklistener,recyclerview,android-recyclerview
I am implementing a Navigation Drawer with a RecyclerView, using this tutorial, but I don't want to apply the whole tutorial, I just want to handle the user's click. I've implemented the onClickListener inside the ViewHolder of my MyAdapter class: public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener{ int...

How to get the width of CardView inside RecyclerView

android,android-layout,recyclerview
So here is my RecyclerView's xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/bikename_recycler" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout> And here's the layout inflated by the RecyclerView's Adapter. <?xml version="1.0"...

Best way to update data with a RecyclerView adapter

android,android-adapter,recyclerview
When I have to use a classic adapter with a listView I update my data in the listView like that: myAdapter.swapArray(data); public swapArray(List<Data> data){ clear(); addAll(data); notifyDataSetChanged(); } I would like to know what is the best practice for a RecyclerView. Because in a recyclerView adapter you can't do a...

RecyclerView onBindViewHolder onclicklistener behavior

android,recyclerview,android-cardview,android-viewholder
I am trying to load a recycler view that lists cards, each card has four elements. two text views(posttext, score are the id) and two buttons(minusOne and plusOne). The code below loads the textview's content and buttons properly on all cards. I try to implement the following behavior. onbuttonclick of...

How to scroll Recyclerview smoothly with inertia effect?

android,android-layout,recyclerview
I am using Recyclerview in my app, i want to give inertia type effect to my scrolling so it doesn't stop suddenly at top and bottom of list, how can i achieve it. Thanks in advance.

getAdapterPosition() is not a method

android,android-studio,recyclerview
in my new Android Project, i have the following Problem, when i want to get the current position in the RecyclerView: Cannot resolve method 'getAdapterPosition()' In my other Android Studio Projects, it's work's fine. public static class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { protected TextView itemName; protected ImageView itemIcon; public...

Item added to the Recycler view every time orientation of the device is changed

android,recyclerview,screen-rotation,android-recyclerview,recycler-adapter
I have a shopping list app that has a bug, when the orientation of the device is changed (Portret to Landscape or the opposite) new item is added. For example, if I have one shopping item like this: and after I change the orientation of the device it is duplicated:...

Recyclerviews in ViewPager

java,android,listview,android-viewpager,recyclerview
I'm trying to get this working: I basically want two Recyclerviews in one ViewPager. I followed this Tutorial: http://android-java-development.blogspot.de/2012/05/system.html, but it doesn't seem to work. I looks like the view pager is empty and the recycler view doesn't show up. Here's my layout code: <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/pager_refresh_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="@dimen/tab_height"> <android.support.v4.view.ViewPager...

RecyclerView ambiguos setVisibility function, clicking on one view affects multiple views

android,listview,textview,android-imageview,recyclerview
This is the project I am trying to run. Here is my code for the onBindViewHolder from RecyclerView.Adapter class @Override public void onBindViewHolder(ViewHolder holder, final int position) { TextView title = (TextView) holder.view.findViewById(R.id.title); final TextView desc = (TextView) holder.view.findViewById(R.id.desc); final ImageView imageView = (ImageView) holder.view.findViewById(R.id.imageView); title.setText(pojos.get(position).getTitle()); desc.setText(pojos.get(position).getDesc());...

Android recyclerview swipe in when loaded

android,animation,android-activity,recyclerview
I am using recyclerview to display search results from a server, and I want to display an animation where it the cards swipe in one after another, so you get a nice swipe effect. How can that be done? This animation can be found on the relay for reddit app...

How to implement ItemAnimator of RecyclerView to disable the animation of notifyItemChanged

android,animation,recyclerview
In my project I need disable the "change" animation of RecyclerView while notifyItemChanged. I investigated in the source of RecyclerView and override android.support.v7.widget.DefaultItemAnimator as below: private static class ItemAnimator extends DefaultItemAnimator { @Override public boolean animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder, int fromX, int fromY, int toX, int toY) { if(oldHolder !=...

Prevent toolbar from hiding when recyclerview has one item

android,toolbar,recyclerview,android-design-library
I have some, problem. The toolbar is hiding when recyclerview has few items (1,2,3,4). This is unwanted behavior. How can i prevent the toolbar from hiding when recyclerview has only few item and there is no scroll on recyclerview? main_recyclerview.xml GIF showing the problem <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:elevation="1dp" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"...

Cardslib's CardView OnCardClickListener's onClick method not being called

android,android-layout,recyclerview,android-cardview,cardslib
I am using this library in my app: Card Library : Guide and created a card as shown in the example. Now I need to handle a click event, but I receive an error when instantiating the following: new Card.OnCardClickListener, which says OnCardClickListener is abstract: cannot be instantiated. In my...

Add RecyclerView(RecyclerFragment) to a Dialog

android,android-fragments,android-alertdialog,recyclerview
I have my custom RecyclerView to create a ListView. And it works great, when I am trying to populate a list view in my layout's id. FragmentTransaction ft = getFragmentManager().beginTransaction(); Bundle bundle = new Bundle(); bundle.putBoolean("enablePullToRefresh", false); GridValues gridValues = new GridValues(); gridValues.rowViewLayout = R.layout.my_detail_row_view; gridValues.delegate = this; mygrid =...

Click through a RecyclerView list item

android,android-layout,android-listview,recyclerview,recycler-adapter
I have a RecyclerView with a LinearLayoutManager and an Adapter: @Override public int getItemViewType(int position) { return position == 0? R.layout.header : R.layout.item; } Here's header.xml: <View xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/header" android:layout_width="match_parent" android:layout_height="@dimen/header_height" /> What I want to achieve is to have a hole in the RecyclerView where I can click through...

Inflating a FrameLayout inside a ViewHolder item during onCreateViewHolder

java,android,recyclerview,custom-adapter
I am trying to create a custom adapter with a dynamic view according to the data retrieved. Everything is set up, I can differentiate the data coming and even implemented getItemViewType and my own getItem to set the type accordingly. What I had: @Override public PostViewHolder onCreateViewHolder(ViewGroup parent, int viewType)...

Add a ListView or RecyclerView to new NavigationView

android,listview,recyclerview,navigationview
I am using the new NavigationView from revision 22.2.0 of the support library by Google. It works perfectly fine to generate a navigation drawer populated using a menu res. I was wondering is it possible to add a ListView or RecyclerView to the navigation drawer so that it can be...

Two RecyclerViews under each other in one layout

android,recyclerview
How can I get two RecyclerViews under each other in one layout? I don't want to have a single RecyclerView for all items. My code: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:background="@color/main__item_background" android:layout_height="match_parent" android:layout_width="match_parent"> <TextView android:text="@string/find_friends__already_playing" android:background="@color/header" android:gravity="center" android:layout_width="match_parent"...

Fragment with RecyclerView : java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true

android,fragment,recyclerview
I keep getting java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true when using Fragment with RecyclerView. I have only 1 Activity which switches between multiple fragments. On activity's onCreate I set the default fragment which happens to have a RecyclerView implemented exactly like in documentation. Upon activity...

RecyclerView in RecyclerView: ItemDecoration

android,recyclerview,android-recyclerview
I'm using a recyclerview (with a vertical LinearLayout) with different viewholders, one of them has another RecyclerView (with an horizontal LL). In this second recyclerView I'm using an ItemDecoration to add a left margin to all of its items but the first. The code in onBindViewHolder of the first RecyclerView...

Android setOnScrollListner on RecyclerView deprecated

android,recyclerview,onscrolllistener
setOnScrollListener is deprecated. Reading the docs from here it tells to Use addOnScrollListener(OnScrollListener) and removeOnScrollListener(OnScrollListener). What is the proper way to add and remove OnScrollListener? Do i need to use removeOnScrollListner in onPause and set it up again using addOnScrollListener in onResume??...

Android - RecyclerView - How do I temporarily prevent scrolling?

android,scroll,recyclerview,cancellation
I have a RecyclerView that I wish to freeze (ie, not allow the user to scroll, but still be able to tap any current visible views) until a certain condition is met. How do I achieve this? I've tried to set an OnScrollListener as following: @Override public void onScrolled(final RecyclerView...

ViewHolder doesn's work anymore after retrieve data from JSON

android,json,recyclerview,android-viewholder
Everything work fine before i implement the json things. When i click the detail button(imageView), dialogFragment should be pop up. It is okay with the pop up, the problem is, it's generate two or more dialogFragment. Is implement json affect the viewholder? Or its related to settag gettag? Here my...

Empty RecyclerView using fetched Data from parse.com

java,android,json,parse.com,recyclerview
I am currently struggling to implement data fetching from a class i created on parse.com. I wanted to retrieve an object which is entitled "flyerDataFetch" and all of its elements to display within a Recyclerview. When I run and compile the program I receive the errors: error:java.lang.NullPointerException at android.view.LayoutInflater.from(LayoutInflater.java:211) Error:...

Set onClickListener on the RelativeLayout contained by CardView

android,android-layout,recyclerview,android-cardview
I am trying to set the onClickListener on each of my CardView elements. Since I was not able to set the onClickListener on the cards themselves (see here), I thought about setting it to the RelativeLayout contained by the cards. Right now I am using the native CardView library and...

Problems with implementing contextual action mode in recyclerview fragment

android,android-fragments,recyclerview,android-actionmode
I hacked together my first app from a bunch of tutorials. With the help of one of them I implemented a RecyclerView inside a fragment which is used by the main activity. Now I found another tutorial which I want to use to implement multi-selection with the contextual action mode....

How can I get the CardView from a clicked widget?

android,recyclerview
In an Android app I have a RecyclerView and a CardView with a layout like the following: CardView | +-- LinearLayout (H) | +-- ImageView[onclick=advance] | +-- LinearLayout (V) | +-- TextView | +-- TextView When a user clicks the ImageView, I want to call a method on the corresponding...

How to call a function after activity is loaded

android,listener,recyclerview,get-childitem
I have an activity in android with a RecyclerView. I am trying to call getChildAt(i) on the RecyclerView in OnCreate but it returns null. I tried the same thing inside a button click listener that I created for testing and it returns the item fine. This must be due to...

Unable to update TextView field inside RecyclerView

android,listview,android-sqlite,recyclerview
I'm migrating from ListView to an RecyclerView and last thing I'm stuck with is updating one of fields. My App has a simple list with some images found on internet. When you choose one, image gets downloaded to a phone for later offline viewing. Adapter gets data from SQLite databaseso...

How to disable RecyclerView item decoration drawing for the duration of item animations

android,animation,recyclerview
I have some basic item decoration which draws some stuff in ItemDecoration.onDrawOver method. This RecyclerView also has DefaultItemAnimator set on it. Animations are working, all is great. Except one thing. When all existing items are swapped with a new item set in this adapter, the decorations are being shown while...

Two object types in a RecyclerView that each have their own ViewHolder

android,recyclerview
Im trying to create recyclerview that displays the results of two different arrays from one single object (ObjectMaster). I dont care the order so much, just as long as both arrays are displayed in the list. Any ideas or suggestions would be extremely appreciated. Model public ObjectMaster { List<Object1> first_objects;...

Ending multiselect in a listview removes list item padding

android-layout,android-listview,recyclerview,android-4.1-jelly-bean
I can only reconstruct this behavior with a JellyBean device (Android 4.1.2 on a Samsung Galaxy S3). With KitKat or Lollipop this problem did not occur. I have a RecyclerView with a list of items which possible multiselect. When I select a few items in the list (the multiselect gets...

Background color or Images shuffling on scrolling in recyclerview?

java,android,recyclerview,recycler-adapter
I am wondering that my images and color of layouts shuffling when i scrolls downwards or upwards, I created cardview using recyclerview. and set an image(changes color on click like to know if its user's favourite item) and setbackgroundcolor(randomly chossen) to the parent layout to make cardview attractive. but when...

android recyclerview doesn't display items

java,android,recyclerview
I want to show these items inside my recyclerview but it doesn't show at all and I can't see the error. Maybe you guys can help me out. MainActivity.java RecyclerView recyclerView = (RecyclerView)findViewById(R.id.rec); List<MenuData> list = new ArrayList<>(); recyclerView.setHasFixedSize(true); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.setLayoutManager(linearLayoutManager); MenuRecAdapter menuRecAdapter = new...

Image adapter leaking memory

android,recyclerview,listadapter,picasso,okhttp
I have a simple ListActivity that shows images and I inizialize my OkHttpClient for Picasso Builder in the constructor of the ImageAdapter class: picassoClient = new OkHttpClient(); picassoClient.interceptors().add(new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Request newRequest = chain .request() .newBuilder() .addHeader("Cookie","xyz") .build(); return chain.proceed(newRequest); } });...

Data on cardview are changed while srolling RecyclerView

android,recyclerview,android-cardview
I am newbie to Android apps development. I have a class, which contains RecyclerView. public class ScreenOne extends Fragment implements SwipeRefreshLayout.OnRefreshListener { private RecyclerView mRecyclerView; private FilmSetAdapter mAdapter; private RecyclerView.LayoutManager mLayoutManager; SwipeRefreshLayout mSwipeRefreshLayout; RequestTask requestTask; ArrayList<Film> listOfFilms; ArrayList<Cinema> listOfCinemas; ArrayList<String> cityIDs; public ScreenOne() { } @Override public View onCreateView(LayoutInflater...

expanding recyclerview item

android,android-animation,recyclerview
if i expand any item in the recyclerview it expands fine but when i scroll down the recylerview i found other items also expanded , due to recycling it took the expanded size not the original one public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.MyViewHolder> implements View.OnClickListener { private LayoutInflater inflater; private Context...

Android RecyclerView Saving State Information

android,recyclerview
I have a RecyclerView whose adapter holds a SortedList of objects I can not modify. My cards inside the RecyclerView should expand/collapse on click showing additional information when expanded. The problem is that there seems to be no way to store the information whether a card is expanded or collapsed...

Infinite scrolling using custom animations in Recycler View not working Android

android,animation,recyclerview,android-recyclerview,recycler-adapter
I have use Wasabeef for Item animation in Recycler view and it works fine. I also want to add infinite scrolling for recycler, for this I am doing like this public abstract class InfiniteScroller extends RecyclerView.OnScrollListener { private int previousTotal = 0; // The total number of items in the...

RecyclerView with only one item displayed on screen

android,imageview,recyclerview
I have RecyclerView with items ImageView. I want to make RecyclerView to display only one item at time, dragging to edge like ViewPager, when changing. Anyone knows how to achieve this? I'm using code from this source: http://hmkcode.com/android-simple-recyclerview-widget-example/ Only one difference is that I don't have TextView, only ImageView....

RecyclerView in FragmentPagerAdaper only updates when screen is rotated

android,android-fragments,recyclerview,fragmentpageradapter
I have a fragment in a FragmentPagerAdpater. The Fragment is basically a RecyclerView. The source for the RecyclerView is provided by a Loader which is inside the Fragment. My problem is that the list appears empty when it is first instantiated. But when I rotate the screen, it appears fine....

Adding a footer view in RECYCLER VIEW?

android,android-adapter,recyclerview,android-recyclerview,recycler-adapter
i want to add a footer layout at the base of the recycler view.Below is my adapter view which inflates header layout as well as other items as well.Help appreciated! public class SplitMembersAdapter extends RecyclerViewAdapter<SplitMember, SplitMemberViewHolder> { private final ArrayList<SplitMember> mSplitMembersList; private final ImageLoader mImageLoader; private static final int TYPE_HEADER...

Can't use RecyclerView in my Android library project

android,gradle,dependencies,recyclerview,android-library
I have an Android library project and want to include a class that extends RecyclerView.Adapter. My build.gradle file includes the following: apply plugin: 'com.android.library' dependencies { compile 'com.android.support:recyclerview-v7:21.0.+' } Despite this, I cannot import RecyclerView in any java file; it even does not show up in the code completions popup...

Nullpointer Exception when using RecyclerView

android,nullpointerexception,recyclerview
I am following an android development tutorial (creating a weather app), but I am stuck at an error that I am getting I indlued the full logcat log at the end of the question. Does anyone has a clue why I am getting this error? I have checked everything more...

Recycler view not showing after parsing json data

android,json,recyclerview,recycler-adapter
I was using static data to populate the recycler view to test. Now after using dynamic data by parsing json the recycler view is not showing up. I have used console to check whether the JSON is getting parsed correctly and it shows correct results. Here is my activity code....

click through RecyclerView empty space

android,recyclerview
I have a layout where a RecyclerView is on top of another layout with a few buttons. The first recycler item is a header with a large top margin to create an empty space above it. Now I want clicks to work through that open space, swiping should also scroll...

Recyclerview scrolling past FAB

android,recyclerview
I'm using a recyclerview and have a FAB on my layout. I want to be able to give a bit of space at the bottom of the last item much like the Gmail app does so when you scroll to the bottom the right hand star on the bottom item...

How should I initialize an array inside RecyclerView Adapter which has the size of a list while the list will not available on Adapter construction?

android,recyclerview
I have a RecyclerView that will contain list of item retrieved from the internet. So at first, the list will be empty. After the data retrieved from the internet, it will update the list and call notifyDataSetChanged(). I can adapt the data into the RecyclerView just fine. But, I have...

Android RecyclerView with Fragments

android,android-viewpager,recyclerview,fragmentpageradapter
I have a ViewPager with a FragmentPagerAdapter. My customer wants me to switch from ViewPager to list; a vertical list with all the fragments. There can be a lot of fragments, so adding them all in a ScrollView is out of the question. Can I somehow do this while still...

Getting null pointer with recycler adapter

nullpointerexception,fragment,recyclerview,android-recyclerview,recycler-adapter
my app is crashing due to a null pointer with the recyclerview adapter in the fragment code. I'm using this adapter to generate a card view list but cannot find out what exactly is causing this null pointer. The log has it happening when setting the adapter r.setAdapter(rA) in the...

View.getChildAt findViewById returns NPE

android,recyclerview
My app utilizes RecyclerView. Here's the xml for the content of each item in the RecyclerView <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/cvExpenses" android:layout_height="wrap_content" android:layout_width="match_parent" card_view:cardCornerRadius="5dp" android:layout_margin="5dp" card_view:cardBackgroundColor="#009dde" > <LinearLayout...

android recyclerview notifyItemInserted animation

android,recyclerview
I don't know why this behaviour is happening, but calling notifyItemInserted(0) (first position only) won't animate the view. Everything works fine in another positions. Animation working in this case: friendsList.remove(positionFriend); friendsList.add(1, newFriend); notifyItemInserted(1); notifyItemRemoved(positionFriend+1); Animation not working in this case: friendsList.remove(positionFriend); friendsList.add(0, newFriend); notifyItemInserted(0); notifyItemRemoved(positionFriend+1); Expected behaviour: Element inserted at...

RecyclerView Viewholder reusing

android,recyclerview
I am creating a recyclerview which will expand itself when the user touches it and closes itself when the user touches it again. Below are my codes: public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.RecViewHolder> { ArrayList<String> values; ArrayList<Integer> expandedPosition; public static class RecViewHolder extends RecyclerView.ViewHolder { ... private boolean resultsOpened = false;...

RecyclerView not displaying my data

java,android,recyclerview
I'm very new to Android and I started practicing with RecyclerView and for some reason my data does not show. If you could help that would be great! Ty. Here's some code. Main Activity: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); recyclerView = (RecyclerView) findViewById(R.id.myRecyclerView); adapter = new myAdapter(getApplicationContext(),...

Checkbox enable EditText in RecyclerView issue

android-edittext,recyclerview
I am working for quiz app project. I've got a RecyclerView, each of them contains TextView, two Checkbox and EditText. What I want is when i checked the second Checkbox it will enable the EditText. I have already make this work. but the problem is if I Checked the Checkbox...

NullPointerException for RecyclerView In fragment

android,android-layout,android-fragments,views,recyclerview
Trying to implement a cards list using the recyclerview inside of a fragment. Every time I run it crashes when trying to open the fragment. I was following this tutorial https://developer.android.com/training/material/lists-cards.html#Dependencies and also this one http://code.tutsplus.com/tutorials/getting-started-with-recyclerview-and-cardview-on-android--cms-23465 Logcat where it crashes. java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setHasFixedSize(boolean)' on a...

Programmatically “swipe-to-dismiss” an item in a ListView/RecyclerView?

android,listview,swipe,recyclerview,android-cardview
I need to be able to programmatically dismiss an item inside a RecyclerView without the user actually swiping (instead I want to dismiss the item when they tap a button in the card). A lot of libraries I've seen only seem to support actual swipes. I've tried using an existing...

ActionBarActivity Show/Hide toolbar not working properly

android,recyclerview,android-toolbar
I am currently developing an app wherein I need the feature to hide the toolbar on scrolling down (like Google+). I am facing issues with it's rendering of toolbar on scroll. Here is how it looks now - I want the toolbar to simply hide on scroll down, but here...

Filter a recyclerview from menu item selection

android,recyclerview,android-recyclerview
In my app I have a recyclerview of images that are populated from a json file. In my toolbar menu, I have included a selection to filter the images based on that selection. Each item in my json is tagged with one of the selection categories (example included). I am...

How could i manually update the recyclerview of my app?

android,android-studio,recyclerview,android-recyclerview
I am new to Android development. I intended on users to submit their information via Google Docs until I created a website for my app. I currently have a recyclerview to display posts. These posts consist of imageviews and textviews. My question is what is the most efficient way I...

Update text within card view list?

android,android-fragments,recyclerview,android-cardview,recycler-adapter
So I have a recyclerview list of card views.I am trying to update the text time text in each view when the user clicks the card, and then reset it back when time has past. I set up an internal method in recyclerviewadapter but when I call updateTimes (calling from...

Android- RecyclerView Adapter - How to implement endless scrolling without deleting previous items

scroll,adapter,recyclerview,infinite
I'm developing an app to get tweets and display them on screen. I've user RecyclerView and it works fine. The thing is that when I get to the last item, I'm swapping the adapter in order to get new items, but the previous items get deleted and I can't scroll...

Return the position clicked in recyclerview in a different Activity?

android,onclick,position,recyclerview
I have a recylcerview in a navigation drawer and I wish to find what position was clicked by the user in the recyclerview in a different activity. The way I have written the code currently always return 0 as the position. Can anyone help me out. Thanks in advance! Recyclerview...

How to change RecyclerView Card's color dynamically

android,material-design,recyclerview,android-recyclerview
I have a RecyclerView that displays cards of same size and similar content. Does anyone knows how I would go about changing the cards color depending on the object it holds? So object "A" would have a blue card and object "B" would have a red card. I've seen visual...