android-recyclerview

RecyclerView - Get the selected position and pass the position to another activity where the same list will appear with that specific item selected

穿精又带淫゛_ 提交于 2020-01-23 12:25:23
问题 I have declared a ViewModel.class for the RecyclerView an Adapter and I have parsed to the MainActivity and to another Activity so I have the same adapter for both activities. I can show the parsed data in both activities but the problem it is I cannot take the data of the selected item to MainActivity and then to set to that btnSearch for a click so then I can share between activities the data from the selected item. Every time when the app is open the first item is selected. What I am

RecyclerView, GridLayoutManager and dynamic Spans count

泄露秘密 提交于 2020-01-23 12:18:49
问题 I encountered a strange bug with the recyclerview . I set and resize spans dynamically to fit with the informations downloaded from an AsyncTask. Sometimes it doesn't display properly. It seems like it displays over the screen.! Then after one or more reload it displays correctly. It seems to go out the screen but I can't figure out why. Here is my adapter: public class ScheduleAdapter extends RecyclerView.Adapter<ScheduleAdapter.ViewHolder> { private List<Schedule> mDataset; /** * First

nested scrollview inside recyclerview not triggering onscrolllistener when scrolling down

北城余情 提交于 2020-01-23 06:22:27
问题 Edit : I have loading more than 200 datas from webservice.When I am scrolling down the recyclerview, it is not triggering the scrollLisener. Because, if I'm not used dy>0 condition, it is loading all next 20 datas, 20 datas and so on, initially when coming to this activity. Below I have posted the code relevant to that. Logcat: E/dy: 0 Activity code: recyclerView = (RecyclerView) findViewById(R.id.rv_list_tab_home_recycler); recyclerView.setHasFixedSize(true); mLayoutManager = new

How to tell RecyclerView to start at specific item position

雨燕双飞 提交于 2020-01-23 06:13:58
问题 I want my RecyclerView with LinearLayoutManager to show up with scroll position at specific item after adapter got updated. (not first/last position) Means the at first (re-)layout, this given position should be in visible area. It should not layout with position 0 on top and scroll afterwards to target position. My Adapter starts with itemCount=0, loads its data in thread and notifies its real count later. But the start position must be set already while count is still 0! As of now I used

Disable all other toggle buttons in recycler view after one is clicked

流过昼夜 提交于 2020-01-23 04:01:11
问题 I am using recyclerView to build a list of toggle buttons (like a numpad), I would like to achieve: when user 'turns on' a button by clicking it, 'turns off' all other buttons I have tried to add an onClickListener inside the view holder class, and call notifyDataSetChanged() such that onBindViewHolder(final ViewHolder holder, int position) is called and then change the state of the button. But it doesn't work, the button clicked does not change its state. ViewHolder class ViewHolder extends

RecyclerView / MapView crashes when rotating device

孤人 提交于 2020-01-23 02:54:18
问题 I have a Android.Support.V4.Fragment that contains both a MapView and a RecyclerView . These are separate views in the Fragment . The app crashes when the device is rotated: Android.OS.BadParcelableException: ClassNotFoundException when unmarshalling: android.support.v7.widget.RecyclerView$SavedState I am passing the lifecycle methods to the MapView as required by the docs: private MapView mapView; private RecyclerView myRecyclerView; private RecyclerView.LayoutManager myLayoutManager; public

RecyclerView: scrollToPosition not working

谁都会走 提交于 2020-01-23 00:04:12
问题 I have a simple project displaying user text messages. I am currently not able to scroll the RecyclerView to the last received text message. My recyclerView is inside a very simple activity using the Coordinator layout: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match

Double Click OnClickListener of a Recycler View Adapter

守給你的承諾、 提交于 2020-01-22 19:32:03
问题 I am trying to add a simple Click View to an item of a recycler view, but for some reason I have to click on an item twice instead of once to perform an action. On single click it seems like that recycler View does not detect a click. On the next one however it detects the click and performs a suitable action. XML : <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/cardView" android:layout_width="match_parent" android:layout_height

Double Click OnClickListener of a Recycler View Adapter

心不动则不痛 提交于 2020-01-22 19:31:46
问题 I am trying to add a simple Click View to an item of a recycler view, but for some reason I have to click on an item twice instead of once to perform an action. On single click it seems like that recycler View does not detect a click. On the next one however it detects the click and performs a suitable action. XML : <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/cardView" android:layout_width="match_parent" android:layout_height

How to reset recyclerView position item views to original state after refreshing adapter

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-22 16:43:06
问题 I have a RecyclerView with rows that have views that when clicked will be disabled for that row position. The problem is after I update the adapter like this: adapterData.clear(); adapterData.addAll(refreshedAdapterData); notifyDataSetChanged(); After refreshing the data, the disabled views at the previous recycler position still remain disabled even though the data is refreshed. How can I reset the views to the original state after refreshing adapter data. 回答1: Use below code. adapterData