android-recyclerview

getAdapterPosition returns -1 in ViewHolder class

核能气质少年 提交于 2019-12-23 06:56:56
问题 I'm trying to show an AlertDialog in my ViewHolder class and after clicking on accept button I'm getting the Model item with getAdapterPosition from a list of items but in Fabric Crashlytics I have 13 crashes because of ArrayIndexOutOfBoundsException which says length is 12 but the index requested is -1 and the crash is for getPaymentMode in this part of code class ViewHolder extends RecyclerView.ViewHolder { TextView time, capacity, description; View button; ImageView avatar; ViewHolder(View

Detect top of reversed RecyclerView

倖福魔咒の 提交于 2019-12-23 05:33:20
问题 I am using a RecyclerView which is reversed like this [like a chat view] mLinearLayoutManager = new LinearLayoutManager(this); mLinearLayoutManager.setReverseLayout(true); mLinearLayoutManager.setStackFromEnd(true); mRecyclerView.setLayoutManager(mLinearLayoutManager); and I am trying to detect when the user scrolls to most top of the RecyclerView I have tried this code but it is not correct mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void

Scroll behavior at RecyclerView into vertical view pager

大兔子大兔子 提交于 2019-12-23 05:23:02
问题 I am using VerticalViewPager and two fragments in it. One of this fragment contains RecyclerView with just regular vertical list. The problem is that I need this list to get to end and then change page at view pager and now view pager always try to intercept RecyclerView scroll. My VerticalViewPager class: public class VerticalViewPager extends ViewPager { public VerticalViewPager(Context context) { super(context); init(); } public VerticalViewPager(Context context, AttributeSet attrs) {

How to retrieve and use the actual ID of a recyclerView Item from the database

六月ゝ 毕业季﹏ 提交于 2019-12-23 05:11:36
问题 Hello Everyone I really need your help here. In The App I am Developing, this is what i want to achieve at the moment. AIM I am trying to divide a school class into sections. E.g Grade One class will have Grade 1A and Grade 1B, Grade Two class will have Grade 2A and Grade 2B etc. This is achieved by clicking a plus Button on the UI which initiates a dialog popup with forms to enter the class sections for the class.The user sees the sections he/she has added by clicking the class name(Which is

Manage Multiple View Types - RecyclerView

。_饼干妹妹 提交于 2019-12-23 05:01:49
问题 I am using this library to display mutiple types of views inside a RecyclerView . Here I am using EnumMapBindAdapter to display userposts list . I have 4 DataBinder classes ,each binder has a list of size 3 (size may change depending on the user posts ) . I have problem with getEnumFromPosition() ,According to my assumptions number of executions of getEnumFromPosition() method should be equal to number of binders (4) . But it is not happening .I have total 4 binders and I assume

LayoutManager.onSaveInstanceState() not working

∥☆過路亽.° 提交于 2019-12-23 04:55:09
问题 I'm trying to save state of my RecyclerView with GridLayoutManager , but when calling onSaveInstanceState() of activity and when I try to call onSaveInstanceState() on layout manager that always return the same object. I trying use method " findFirstVisibleItemPosition ", but it always return -1. RecyclerView has adapter, adapter has some amount of elements, I can scroll them! I don't know why I can't get item position of fully initialized and working component ! Please help! There is my code

Save new positions in Room after recyclerView drag & drop

放肆的年华 提交于 2019-12-23 04:48:12
问题 I've implemented a recyclerView with a drag and drop feature in my app. Everything works fine until the app is relaunched --any drag and drop changes were not saved/remembered by the app. I've tried: Using SharedPreference + GSON Reading other SQLite answers here on SO like this one: Store new position of RecyclerView items in SQLite after being dragged and dropped Reading Paul Burke's Medium Post My current code looks like this: In onCreate ItemViewModel itemViewModel = ViewModelProviders.of

correct way to implement item touch helper on recyclerview in android

心不动则不痛 提交于 2019-12-23 04:44:04
问题 i followed a tutorial here on how to implement onItemTouchHelper and callback methods when i run my code it works to the point that i can long press and pick up the item but the moment i move it past one of the other items in the list my app will force close with an index out of bounds exception can anybody here help me? here is my code but it is identical to the code in the tutorial, Simple Item Touch Helper Callback public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback

RecyclerView inside viewpager

放肆的年华 提交于 2019-12-23 04:43:12
问题 I try to implement a layout like below image. in this layout first ViewPager has fix height and second Viewpager contain RecyclerView . How can connect scroll RecyclerView in Viewpager to NestedScrollView in parent? I try this: nestedScrollView.isFillViewport = true but RecyclerView scroll from top of Viewpager . 回答1: I have faced this issue some time ago. Where you want RecyclerView to be Scrolled by NestedScrollView . And nestedScrollingEnabled will not help you because RecyclerView is

Error CS0115 '…OnBindViewHolder(Object, int)': no suitable method found to override

蓝咒 提交于 2019-12-23 04:38:35
问题 I'm binding this library: https://github.com/mancj/MaterialSearchBar And generally it works, however, I have an issue when I try to add the support of the RecyclerView, I added the following libraries: And I got the following errors: I tried to follow this advice of creating some partial classes: xamarin.android binding thorw 'does not implement inherited abstract member 'RecyclerView.Adapter.OnCreateViewHolder(ViewGroup, int)' But it didn't work and I started to get duplicates, personally, I