android-recyclerview

How to check if first item of RecyclerView is visible on the screen

时光毁灭记忆、已成空白 提交于 2020-05-13 11:53:12
问题 Is it possible to check if the first or second item of the RecyclerView is visible on the screen of the user? For example when the user scrolls down: if (first item not visible to user) { // do something } else if ( first item is visible){ // do something } What I currently do is I add a listener to my recycler so that when the user scrolls down, it will do something and scroll up. recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled

Page(s) contain a ViewGroup with a LayoutTransition (or animateLayoutChanges=“true”), which interferes with the scrolling animation

醉酒当歌 提交于 2020-05-13 07:35:55
问题 I use fragments with ViewPager2, and I notice two relevant IllegalStateExceptions in production (I can't reproduce it myself) occurring in devices like Xiaomi, Yulong, asus, vivo running Android 8 or 9: Fatal Exception: java.lang.IllegalStateException: Page can only be offset by a positive amount, not by -758 at androidx.viewpager2.widget.ScrollEventAdapter.updateScrollEventValues(ScrollEventAdapter.java:280) at androidx.viewpager2.widget.ScrollEventAdapter.onScrolled(ScrollEventAdapter.java

Allow Recyclerview Items to scroll past top of Recyclerview

孤街浪徒 提交于 2020-05-13 07:27:53
问题 I have a RecyclerView list, in which I want the currently selected item to be shown at the top of the RecyclerView . I still however, want the entire list to be scrollable, therefore, removing views from above the selected item is not a possible solution. It seems I need a mechanism where the RecyclerView items are able to scroll beyond the bounds of the RecyclerView . I'm not sure if this is possible, so if it is not, does anyone have a solution to ensuring the currently selected item

how to get ID of the items in recyclerview

一世执手 提交于 2020-05-12 09:01:30
问题 i'm using slide to delete from recyclerview but the problem comes when getAdapterPosition() doesn't match with the row_id of sql table. how can i get id from the adapter and how to update recyclerview when the data is added(it doesn't display new data until i reopen the app or change orientation) ? public class MainActivity extends AppCompatActivity { RecyclerView mRecyclerView; MyAdapter myAdapter; ImageButton floatButton; DbHelper dbHelper; ArrayList<Information> data; @Override protected

how to get ID of the items in recyclerview

|▌冷眼眸甩不掉的悲伤 提交于 2020-05-12 09:01:12
问题 i'm using slide to delete from recyclerview but the problem comes when getAdapterPosition() doesn't match with the row_id of sql table. how can i get id from the adapter and how to update recyclerview when the data is added(it doesn't display new data until i reopen the app or change orientation) ? public class MainActivity extends AppCompatActivity { RecyclerView mRecyclerView; MyAdapter myAdapter; ImageButton floatButton; DbHelper dbHelper; ArrayList<Information> data; @Override protected

Recycler View: Inconsistency detected. Invalid view holder adapter positionViewHolder

孤人 提交于 2020-05-09 17:52:10
问题 Recycler View Inconsistency Detected error, coming while scrolling fast or scrolling while loading more items.. FATAL EXCEPTION: main Process: com.pratap.endlessrecyclerview, PID: 21997 java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{56a082c position=40 id=-1, oldPos=39, pLpos:39 scrap [attachedScrap] tmpDetached no parent} at android.support.v7.widget.RecyclerView$Recycler.validateViewHolderForOffsetPosition(RecyclerView.java:4251)

How to add a search filter in RecyclerView to filter through parsed JSON data? edited

天涯浪子 提交于 2020-05-09 17:22:49
问题 I am developing an android app which shows a list of countries affected by Coronavirus , the total number of confirmed cases and total Deaths. I am using a JSON API to get the data and displaying it using a RecyclerView . The app works fine , and i get a list of all the countries with their respective case counts. I want to add a search option so that the users can filter the list and find a specific country. How do i do that? I am new to programming , if someone could help with this that

setRecycledViewPool method in RecyclerView

无人久伴 提交于 2020-05-07 19:20:27
问题 I am trying to understand what the setRecycledViewPool method actually does along with the RecyclerView in the following line of code where mrecyclerView is a RecyclerView object: mrecyclerView.setRecycledViewPool(new RecyclerView.RecycledViewPool()); I read the Android documentation link and I still don't understand what it does clearly. Can someone explain to me its use and when to use it? 回答1: setRecycledViewPool(...) can be useful when we have a nested RecyclerView. See this blog post for

RecyclerView with different types and different adapter

故事扮演 提交于 2020-04-30 11:11:27
问题 and thank you for your attention to my request. I'm a newbie on Andorid Studio and I'm developing an App, it has to show a list of Events, Courses and News. There is a DrawerLayout which allow navigating into Event's, course's and news's area, each area has each specific RecyclerView, but into the home activity, I have to show all the items (Event, Course and News). I create an Adapter for each item (because they have different properties) and each section (fragment) works properly but now I

Margin between items in recycler view Android

女生的网名这么多〃 提交于 2020-04-29 06:08:51
问题 Hi I am Following this tutorial: http://www.journaldev.com/10024/android-recyclerview-and-cardview-example-tutorial Now I am facing a weird issue the margin between each CardView item inside RecyclerView is way too much. ISSUE How to reduce the Margin between each item of CardView placed inside RecyclerView ? 回答1: I faced similar issue, with RelativeLayout as the root element for each row in the recyclerview. To solve the issue, find the xml file that holds each row and make sure that the