FAQ Database Discussion Community


ScrollingViewBehavior for ListView

android,android-listview,android-support-library,android-recyclerview
I have two activities using AppBarLayout with a Toolbar and TabLayout from support library 22. The layout of both is pretty similar: A Toolbar at the top, below it TabLayout, below it a ViewPager containing 3 Fragments. The first activity's Fragment has a RecyclerView, the second activity's Fragment is using...

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...

Parent click event not firing when recyclerview clicked

android,android-cardview,android-recyclerview
I have a RecyclerView which is in a CardView that has a couple of TextViews. The CardView has a OnClickListener set and is fired off when clicking on the TextViews, but does not fire when clicking on the RecyclerView. Here is what the CardView looks like: <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView...

CardView and RecyclerView divider behaviour

android,android-layout,android-listview,android-cardview,android-recyclerview
I am trying to use RecyclerView with CardView as an single item of the list. I want to implement horizontal list, with LayoutManager it is really easy. So I started to implement it. It seems that everything works, but not as I expected here is the result using CardView as...

Scolling with multiple RecyclerViews in Layout

android,scrollview,android-linearlayout,android-recyclerview
I have created a layout which has two RecyclerViews. One scrolls horizontally while other scrolls vertically. I can scroll correctly inside each RecyclerView but the page as a whole won't scroll i.e. top RecyclerView stays at top always and bottom one stays at bottom like both are fixed in position....

Header TextView With RecyclerView

android,android-recyclerview
I am using RecyclerView + CardView to show a list of text now I am trying to add a plain TextView header to the top of the RecyclerView so I have the two layouts inside the adapter but now it shows like this in the app: And it must look...

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...

How to keep the status of the ViewHolder in RecyclerView

android,android-cardview,android-recyclerview
I have a RecyclerView which includes a few grid cells. There is a TextView above CLICK ME button. I'll show something for example, the name at the TextView when button is clicked. The problem for me is the text inside the TextView is not persistent. Here is my code in...

Sliding Tabs With RecyclerView Showing Blank

android,android-fragments,android-cardview,android-recyclerview
I am using Sliding tabs with RecyclerView to show text and images and I think I have it setup correctly but for some reason it is just showing blank in each tab can someone please tell me what is wrong? This is how it should look But it's just showing...

Android how to send an Intent from a fragment when a RecyclerView item is clicked

android,android-intent,android-fragments,android-recyclerview
My app is coded with a RecyclerView that is contained within a fragment. I'm able to successfully populate the RecyclerView with a list of mock data, however I don't how how to send an Intent to another Activity when one of the items is clicked. When I try to call...

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...

Android RecyclerView notifyItemRangeChanged vs notifyItemChanged

android,performance,android-animation,android-recyclerview
I have a dataset that possibly changes upon refresh. It's quite unpredictable to determine which entries in the existing dataset has been changed. I read through the recyclerview adapter desciptions and the main question I have is. Is it more efficient figuring out which data-view changed, then use notifyItemRangeChanged for...

Sliding Tabs With RecyclerView

android,android-recyclerview
I want to display text and images in sliding tabs using the RecyclerView. I think I have it setup correctly to this point and I think the last piece of the puzzle is the LayoutManager but it gives me an error under the onCreateView I already made a variable for...

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...

notifyDataSetChanged() doesn't work with my custom adapter

android,android-fragments,android-adapter,android-recyclerview
I've created a simple RecyclerView.Adapter and it displays the content properly, but when I call notifyDataSetChanged() on it - it doesn't work. PastEventFragment public class PastEventFragment extends Fragment { private RecyclerView mRecyclerView; private List<PastEventItem> mPastEventItemList; private PastEventAdapter mPastEventAdapter; public PastEventFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle...

how to have variable row height in recyclerview

android,android-recyclerview
I am trying to create a recyclerview in a nav drawer with the header showing the profile information. I would like to have a header height more than the other row elements. below is my header layout <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="200dp" android:background="@color/green" android:orientation="vertical" android:weightSum="1"> <LinearLayout android:layout_width="match_parent"...

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...

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:...

Skipped 46 frames! The application may be doing too much work on its main thread

java,android,for-loop,android-recyclerview
I'm trying to use the RecyclerView and put eight images in the adapter dynamically. I have also the titles of each image so i create 2 arrays and with a for loop with multiple condition i can set what i want. It works but not as i want. Infact i...

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...

RecyclerView With Two Layouts

android,android-recyclerview
I am trying to put a Header TextView at the top of my RecyclerView so I have put two layouts inside my RecyclerView I have followed some tutorials and tried to modify the code up to here but I can't get it right Under onCreateViewHolder it gives me a cannot...

RecyclerView With CardView

android,android-cardview,android-recyclerview
I am using RecyclerView + CardView to list all the countries from A-Z like I have here But I want them to line up next to each other so save space like this What is the best way to achieve this? CardAdapter public class CardAdapter extends RecyclerView.Adapter<CardAdapter.ViewHolder> { List<Nationality> mItems;...

startActivity() on a RecyclerView Item [duplicate]

android,onitemclick,android-recyclerview
This question already has an answer here: How to open a different activity on recyclerView item onclick 2 answers I need to start an activity based on the item a user clicks on a RecyclerView. The code below has the position as a reference. Does anyone knows how to...

match_parent width does not work in RecyclerView

android,android-recyclerview
My RecyclerView and item has match_parent width but the result is : <view class="android.support.v7.widget.RecyclerView" android:layout_width="match_parent" and items: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/apk/res-auto" android:id="@+id/ll_itm" android:orientation="horizontal" android:layout_width="match_parent" full: <?xml version="1.0" encoding="utf-8"?> <LinearLayout...

How to use custom view inside recyclerview item?

android,android-custom-view,android-recyclerview
I'm trying to use ProgressWheel inside each item of RecyclerView. It works fine without ProgressWheel but the Exception comes I use this ProgressWheel inside RecyclerView item. Everytime, it is giving me the following exception after adding ProgressWheel: 05-04 18:33:06.311: E/AndroidRuntime(738): FATAL EXCEPTION: main 05-04 18:33:06.311: E/AndroidRuntime(738): android.view.InflateException: Binary XML file...

how to show selection of the lst item in recycler view in android?

java,android,android-layout,android-5.0-lollipop,android-recyclerview
I have implemented the recycler view in navigation drawer in android.This is working fine.I am able to switch between item by clicking on recycler view item. but i am not able to change the background color for the selected item.please suggest me how to imeplement it.I have tried this so...

Android RecyclerView with LinearLayout

android,android-recyclerview
I have been reading about Google's Material Design and ran across the new RecyclerView for Android. I have been following Google's tutorial but their example is very slim and I want to do more dynamic things with my RecylerView and I was hoping someone could help explain how to do...

how to call RecyclerView in the first fragment of the navigation drawer? I've followed a tutorial by slidenerd but getting one error

android,android-fragments,android-navigation,android-recyclerview
This is the Java file of the fragment I wish to insert recycler view. Please dont worry about the package name which I deleted for some reasons. import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.ArrayList; import java.util.List; public class Dashboard...

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...

Android RecyclerView Item Separator

android,xml,android-styles,recyclerview,android-recyclerview
I am using RecyclerView with rounded corner, to make it rounded corner I used below XML: view_rounded.xml:- <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#008f8471"/> <stroke android:width="2dp" android:color="#ffffff" /> <corners android:radius="10dp"/> </shape> fragment_main.xml:- <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view"...

How to implement a chat list view with heterogenous row types (image video and text) using listview?

android,android-listview,chat,android-recyclerview
I'm building a normal chat application. Image,text and videos can be sent hence I need multiple row styles in my list. I used listview. But Listview returned (after recycling rows) wrong rows many times and my attempt failed. Any Idea how to do this? Can this be done using RecyclerView?...

No data inside the custom adapter

android,android-adapter,android-viewholder,android-recyclerview
This code is from slidenerd tutorial for recyclerview im trying to bind the data to the recyclerview using getdata function public static List<Information> getData() { List<Information> menuData=new ArrayList<>(); int[] icons={R.drawable.ic_bluetooth,R.drawable.ic_crosshairs_gps,R.drawable.ic_laptop,R.drawable.ic_remote}; String[] titles={"Bluetooth","GPS","Laptop","Remote"}; for(int i=0;i<titles.length&&i<icons.length;i++) { Information current =new Information(); current.iconID=icons[i];...

Zebra-striping color-effect on RecycledView widget rows

android,android-recyclerview
What I'm trying to do is to assign a different color to every other row in a RecycledView. I created a custom RecycledView.Adapter, and in onCreateViewHolder method I have this: // Create a row_folder view View view = inflater.inflate(R.layout.row_folder, parent, false); if(position % 2 == 0) { view.setBackgroundColor(Color.BLACK); } //...

Toolbar not showing with swipe to refresh

android,android-recyclerview,swiperefreshlayout,android-design-library
I'm trying to implement collapsing tollbar with swipe to refresh and recyclerview. When I'm trying to scroll (when recyclerview has only one item) toolbar collapse, but when I'm trying to scroll down to show toolbar, it's impossible because swipe down causes swipe to refresh. When recyclerview has more item it...

Convert RecyclerView items to CardView on click

android,android-layout,android-cardview,android-recyclerview
I want to change my RecyclerView items to a CardView with a few buttons(that I'll do by myself). I don't understand how to convert it to a cardview on click. Here's my code: MainActivity.java public class MainActivity extends AppCompatActivity { RecyclerView recyclerView; RVAdapter rvAdapter; @Override protected void onCreate(Bundle savedInstanceState) {...

RecyclerView.Adapter custom filter exception

android,android-adapter,android-recyclerview
I have a custom RecyclerView.Adapter class where I implemented a Filterable and used the interface method override like so: private MyFilter myFilter = new MyFilter(); // Class implemented below and also implemented the: @Override public Filter getFilter() { return myFilter; } This is MyFilter class implementation: public class MyFilter extends...

RecyclerView Issue with Child Items Visibilities

android,android-5.0-lollipop,recyclerview,recycler-adapter,android-recyclerview
Hey guys I am creating chatting app something like whatsapp but facing issue with Childs Visibilties in RecyclerView here it contains my message and message from server I've defined the two items for my message and server message in single layout and I'm Setting Visibility Based on the Boolean ;...

How to check which item was clicked in a recyclerview child

android,android-recyclerview
The recyclers child view contains two click-able objects , one is a set of TextViews and ImageView, the other one is a CheckBox (Refer - Android Recyclerview Multiple onclick items) I want to see if on the child the checkbox is clicked or not. If so, then I change the...

Android RecyclerView.Adapter onCreateViewHolder() working

android,android-recyclerview
I am using RecyclerView.Adapter but I am little confused regarding working of its method onCreateViewHolder. @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { if(viewType==TYPE_ITEM) { View mView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.inflate_common_item, viewGroup, false); ViewHolder vh = new ViewHolder(mView); return vh; } else { View mView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.inflate_uncommon_item, viewGroup, false); ViewHolderFooter vh =...

Know when RecyclerView items are shown for the first time (Android)

android,google-analytics,visible,android-recyclerview,staggeredgridlayout
I'm trying to use Google Analytics Enhanced Ecommerce to send "impressions" of my products on a RecyclerView StaggeredGrid. Every time a user scroll, I check which products are visible and send a Hit: public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) { for (int i...

how to open a different fragment on recyclerview OnClick

android,android-fragments,android-recyclerview
I am facing a familiar issue.I am using a recycler view to display my drawer list item in my navigation drawer.OnClick of the drawer list item i am able to open different activities,however i would like to be able to open fragments which will be replacing the main activity layout.Is...

SeachView + RecyclerView

android,searchview,recycler-adapter,android-recyclerview
I search a lot for my question and didnt find good explain how to serch through RecyclerView , I have List<BaseOfCards> (BaseOfCards is my getter&setter class) My RecyclerViewAdapter : public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.MyViewHolder> { private LayoutInflater inflater; private List<BaseOfCards> items; //private int itemLayout; //String cardvalue; private Activity mActivity; public...

How to display image and text from Cardview in another activity onClick?

android,onclicklistener,android-cardview,android-viewholder,android-recyclerview
I have a sample app from exoguru which contains cardview each card consists of an image and corresponding text .Now how to display that image and text in another activity on clicking that particular card? Here is the screenshot Here is the ViewHolder which contains the onclick for the cardview...

Android: OnClickListener of Button on CardView

onclicklistener,android-context,android-cardview,android-recyclerview
I'm a bit of a newbie so I apologize if this is an easy question. I'm following this tutorial: http://www.truiton.com/2015/03/android-cardview-example/#comment-7174 It shows how to make a few CardViews in a layout with 2 TextViews in each - all programmatically. I would like to modify it to have a Button instead...

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...

How to add Ripple effect in RecyclerView

android,android-animation,android-recyclerview
I would like to add this nice effect to my RecyclerView items but I don't know where to start. If somebody knows a good and simple tutorial on this topic I would appreciate sharing it with me.

RecyclerView is always null

android,android-fragments,android-support-library,android-recyclerview
I am trying to implement a RecyclerView in my app, but I can't make it work at all. It throws NPE and I can't find out why, because I've done everything according to official Google tutorials. Logcat output: 04-26 23:04:41.823 22356-22356/com.example.app W/dalvikvm´╣Ľ threadid=1: thread exiting with uncaught exception (group=0x41670d88) 04-26...

NullPointerException for adapter.notifyDataSetChanged?

android,android-adapter,android-recyclerview
I have a RecyclerView that get me crash in adapter.notifyDataSetChanged(); : public class ListContent extends Activity { String _comment; public ArrayAdapter adapter; RecyclerView recList; Context context; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_listcontent); recList = (RecyclerView) findViewById(R.id.cardList); recList.setHasFixedSize(true); LinearLayoutManager llm = new LinearLayoutManager(this); llm.setOrientation(LinearLayoutManager.VERTICAL);...

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...