Tag: recyclerview

Android RecyclerView Error

today I was trying to use the new android RecyclerView. I have created a new Project with a blank activity and added the following to its layout: <android.support.v7.widget.RecyclerView android:id=”@+id/my_recycler_view” android:scrollbars=”vertical” android:layout_width=”match_parent” android:layout_height=”match_parent”/> In gradle build dependencies I have added: compile ‘com.android.support:support-v4:21.0.0’ compile ‘com.android.support:recyclerview-v7:21.+’ compile ‘com.android.support:cardview-v7:21.+’ But the activity_main.xml rendering still shows me the following error: […]

How to consistently add alternating backgrounds to item views in RecyclerView

Up until now I used the Adapter’s onBindViewHolder to set an alternating background based on the item’s Adapter-Position. @Override public void onBindViewHolder(ViewHolder holder, int position) { holder.itemView.setBackgroundResource(position % 2 == 0 ? R.color.list_item_background_alternating : R.color.list_item_background); … } However, this is getting more an more complicated when doing more than just showing a list. For example: […]

PopupMenu is not positioned properly inside RecyclerView

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 the first two items seem […]

RecyclerView with GridLayoutManager

This question already has an answer here: Recycler View With Gridlayout Manager 1 answer

RecyclerView Multiple Layout View(s) in an Adapter class

Here is what I have achieved ? 3 different sections, 10 different items in each section. Here is the tutorial link I am following and below is the Screenshot: Trying to show different Views for each and every Section. Like: For Section 1 (layout_1.xml) For Section 2 (layout_2.xml) For Section 3 (layout_3.xml) But showing layout […]

No adapter attached; skipping layout

logcat error : No adapter attached; skipping layout I changed the context argument with getActivity(), but the app is still not running. public class FragmentActivity extends Fragment { private RecyclerView mRecyclerView; private CountryAdapter mAdapter; private LinearLayoutManager layoutManager; public FragmentActivity(){} @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.activity_main, container, false); […]

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

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()); imageView.setImageResource(pojos.get(position).getImage()); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View […]

RecyclerView with GridLayoutManager trying to solve wrap_content

I try to solve the following: using RecyclerView with GridLayoutManager with fixed cell-widths recyclerview resizing only to the necessary height (wrap_content) I try to use the following code, the problem is that it doesn’t work, and I haven’t found any working example not mentioning to redraw properly when orientation changes. public class AutofitRecyclerView extends RecyclerView […]

Recyclerview addOnItemTouchListener get whichsubview is clicked inside row

I’ve implemented Recyclerview onclickListener from this Stack overflow solution. This solution works fine for the recycler item clicks. But I can’t able to get which subview(ex: ImageView,Button) is clicked from the row. mAttachmentRecyclerview.addOnItemTouchListener( new RecyclerItemClickListener(getApplicationContext(), new RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View view, int position) { if (view.getId()==R.id.attachmnet_remove) { attachmentsList.remove(position); mAttachmentAdapter.notifyDataSetChanged(); attachmentCount–; } } } […]

Android ViewPager with RecyclerView works incorrectly inside BottomSheet

When I try to scroll list, sometimes this works incorrect – BottomSheet intercepts the scroll event and hides. How to reproduce this: Open Bottom Sheet Change a page of ViewPager Try scroll the list Result: BottomSheet will be hidden. Here is sample code: compile ‘com.android.support:design:23.4.0′ MainActivity.java package com.nkdroid.bottomsheetsample; import android.os.Bundle; import android.support.design.widget.BottomSheetBehavior; import android.support.design.widget.TabLayout; import […]

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