Tag: recyclerview

Disable click on RecyclerView inside a SwipeRefreshLayout

I implemented a SwipeRefreshLayout using a RecyclerView and I need that my adapter items are disabled during the OnRefreshListener. I tried the following approach, but the click occurs normally: mRecyclerView.setEnabled(false); mRecyclerView.setClickable(false);

Recyclerviews and SwipeRefreshLayout using support library 23.2.0

Has anyone figured out a way to get recyclerviews, AppbarLayouts and SwipeRefreshLayout to work together on 23.2 yet? I am using a pretty standard method I think, but the swiperefreshlayout keeps grabbing the scroll gesture when trying to move up the recyclerview. <android.support.design.widget.CoordinatorLayout android:layout_width=”match_parent” android:layout_height=”wrap_content”> <android.support.design.widget.AppBarLayout android:id=”@+id/appbar” android:layout_width=”match_parent” android:layout_height=”wrap_content”> <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:theme=”?attr/toolbar_theme” app:layout_scrollFlags=”scroll|enterAlways” […]

RecyclerView not recycling views if the view count is small

I’ve been dealing with a strange behavior in Recycler View, if the view count in the adapter is small, in my case with size 5, the views are not being recycled and onBindViewHolder is not called when the view is scrolled back to screen. If i increase the size to 10 views for example, then […]

Changing color of single drawable in RecyclerView will change all drawables

I just tried to change the color of my drawable inside my row depending on a value but instead of one drawable the adapter changed all of them. Here is my Adapter: public class ReportAdapter extends RecyclerView.Adapter<ReportAdapter.ReportViewHolder> { DataBaseHelper dataBase; private LayoutInflater inflater; List<ChoosedSubject> data = Collections.emptyList(); Context context; OnItemClickListener itemClickListener; public ReportAdapter(Context context, List<ChoosedSubject> […]

How can I remove OnClickListeners from RecyclerView's ViewHolders when they are disposed?

I am using RecyclerViews in my app project and setting OnClickListeners with their ViewHolders (in their constructors like mentioned in a StackOverflow Q&A). Then I have this question: how can I remove OnClickListeners from RecyclerView’s ViewHolders when they are disposed. Usually, we can remove an OnClickListener by doing this: view.setOnClickListener(null); And if it is a […]

Unable to compile my android project

When i try to compile my android project iam getting the following error. Error:A problem occurred configuring project ‘:app’. Could not resolve all dependencies for configuration ‘:app:_debugCompile’. Could not find com.android.support:appcompat-v7:21.0.1. Searched in the following locations: https://jcenter.bintray.com/com/android/support/appcompat-v7/21.0.1/appcompat-v7-21.0.1.pom https://jcenter.bintray.com/com/android/support/appcompat-v7/21.0.1/appcompat-v7-21.0.1.jar file:/home/baman/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/21.0.1/appcompat-v7-21.0.1.pom file:/home/baman/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/21.0.1/appcompat-v7-21.0.1.jar file:/home/baman/Android/Sdk/extras/google/m2repository/com/android/support/appcompat-v7/21.0.1/appcompat-v7-21.0.1.pom file:/home/baman/Android/Sdk/extras/google/m2repository/com/android/support/appcompat-v7/21.0.1/appcompat-v7-21.0.1.jar Required by: SriLankaTemples:app:unspecified Could not find com.android.support:recyclerview-v7:21.0.1. Searched in the following locations: https://jcenter.bintray.com/com/android/support/recyclerview-v7/21.0.1/recyclerview-v7-21.0.1.pom […]

RecyclerView java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position when resume from added fragment

Can you guys help me on this here is my code to add fragment mRecyclerView.addOnItemTouchListener( new RecyclerItemClickListener(getActivity(), new RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View view, int position) { if (!IsScrolling) { Fragment fragment = new ProductInfoFragment(); Bundle bundle = new Bundle(); bundle.putString(“prodID”, mItems.get(position).getproductID()); bundle.putString(“catName”, catName); fragment.setArguments(bundle); FragmentManager fragmentManager = getActivity().getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); […]

ViewPager fragments are all referencing the same RecyclerView and/or Adapter

I have a Fragment that contains a RecyclerView to display events for a given day. I am using a ViewPager to separate the Fragments into multiple days; A Fragment for Saturday’s events and a Fragment for Sunday’s events. However, it appears that both Fragments are referencing the same RecyclerView and/or Adapter, as it is only […]

Get list of checked checkboxes from recyclerview android

I have populated the recyclerView with image, title and checkbox. I have two problems. How to make the checkbox selected when the imageview or the whole recycler item is clicked. I have to go to next activity by getting all the checked items from the recyclerview. My layout : <RelativeLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_margin=”8dp”> <ImageView android:id=”@+id/image” […]

RecyclerView content height

Is there any good way of getting the height of the content inside RecyclerView? Considering all items may have different height. In my scenario I’m using a LinearLayoutManager. I’ve searched around and found surprisingly few results for this problem.

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