recycler-adapter

Problems with dynamic views inside recycler view

核能气质少年 提交于 2019-12-23 10:28:57
问题 I'm using recycler view to show list of items which contains grid layout of images. The grid layout is added dynamically to the list item inside "onBindViewHolder" method on recycler view adapter. Now problem is that the grid layout views are recreated on every scroll. I don't want those views to be recreated on scroll. How to deal with it?? Here is the code snippet @Override public void onBindViewHolder(final PersonViewHolder personViewHolder, final int i) { GridLayout feedGrid = new

RecyclerView + MediaPlayer + Toggle Button + String Uri

放肆的年华 提交于 2019-12-23 10:15:16
问题 Background: I'm working on an Fitness app. Everything is working good till now but problem came when I was working with audio files MediaPlayer in android. I have checked resources and found ListView but couldn't find anything on RecyclerView + MediaPlayer. I want to know how to make it work while working with RecyclerView + Toggle Button + String Uri (Offline - Raw folder) Problem: Right now it is playing the first .mp3 file on every click event (for Eng: R.raw.sample_one_eng is played and

RecyclerView scrolls to top on notifyDataSetChanged in chat screen

痞子三分冷 提交于 2019-12-23 06:58:30
问题 I am trying to create messaging kind of screen using recyclerView which will start from bottom and will loadMore data when user reached top end of chat. But I am facing this weird issue. My recyclerView scrolls to top on calling notifyDataSetChanged. Due to this onLoadMore gets called multiple times. Here is my code: LinearLayoutManager llm = new LinearLayoutManager(context); llm.setOrientation(LinearLayoutManager.VERTICAL); llm.setStackFromEnd(true); recyclerView.setLayoutManager(llm); ** In

start Fragment from RecycleView Adapter Onclick

安稳与你 提交于 2019-12-23 04:26:49
问题 Hi I have A RecycleView Adapter and A button. I want that button to start a Fragment. I can start an activity but not a fragment. I have tried this Onclick method for my Button @Override public void onClick(View v) { Bundle bundle = new Bundle(); bundle.putParcelable("event", events.get(getLayoutPosition())); Fragment fragment = new EditEventDetailFragment(); fragment.setArguments(bundle); fragment.getFragmentManager().beginTransaction().replace(R.id.contentMainDrawer,fragment).commit(); }

sorting in recycler view by size,date,name .etc and remember choice

倖福魔咒の 提交于 2019-12-23 02:42:13
问题 I am making gallery app and I want to add sorting to it I can sort item at run time by using Comparator but problem is whenever I quit app the list came form database again and all the list is unsorted I want to give option in my app to sort by date,size, name etc can you guys help how can i ahcevie this and remmeber user's choice if he next time run the app I have also read about sorted-list please tell me what is solution to my problem or any sample code currently I am doing this like this

RecyclerView scrolling to the bottom

一世执手 提交于 2019-12-23 02:32:29
问题 I have a recyclerView with 100+ items. When user will open the activity containing the recyclerView, recyclerView's bottom should be visible without any scrolling effect. Directly last page of the adapter should be shown like whatsapp's chatting page. I have tried by following way, but it is showing the scrolling effect when user opens the activity. recyclerView.smoothScrollToPosition(list.size()); 回答1: You can scroll to last position of recycler view by adding this line recyclerView

Change layout screen in runtime with RecyclerView adapter

我是研究僧i 提交于 2019-12-22 14:06:05
问题 I have two layout files shown below. If data is present in list then I show this layout. and when list is empty then I show this layout. Now I wanted to change layout at runtime. When ever user deletes last item from list I wanted to change layout to 'Empty cart layout' shown in second image. In getItemCount() method of RecyclerView adapter if list is empty or null then I return count as 1 otherwise I return list.size() This is my adapter code. public class CheckOutAdapter extends

How to properly use LiveData with RecycleView

感情迁移 提交于 2019-12-22 08:12:02
问题 I have a project that loads a list from the server. This data will eventually be stored into a database, but for now is stored in memory in a MutableLiveData. A RecyclerView's adapter is watching the data and displaying it. So far everything is working as expected, using a FAB the user can post a new entry which will go at the top of the list, on success I get a 200 and here's the main part where I'm getting lost... When I want to add a single item to a list stored in a LiveData, the observer

Why to use static with RecyclerView.ViewHolder [duplicate]

巧了我就是萌 提交于 2019-12-22 07:01:41
问题 This question already has answers here : What difference between static and non static viewholder in RecyclerView Adapter? (3 answers) Closed 4 years ago . Why is recommended to use static for a class extended from RecyclerView.ViewHolder if I create a new instance of this class on the onCreateViewHolder method and I guess that instance is used for each item: @Override public RecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent

Android : Change cart menu badge counter from Recycler Adapter

不羁岁月 提交于 2019-12-21 06:25:25
问题 I am trying to develop e-commerce type of app in which user can add item to cart. But I am unable to update the cart badge counter from adapter. Here is screenshot of my app. I am using Recycler view inside fragment. And I am referring this below link for menu item count. https://mobikul.com/adding-badge-count-on-menu-items-like-cart-notification-etc/ My problem is I cannot access menu item from adapter. Here is my fragment code. PriceListFragment.java public class PriceListFragment extends