android-recyclerview

How to prevent auto scroll in RecyclerView after notifyDataSetChanged?

☆樱花仙子☆ 提交于 2019-12-22 12:37:32
问题 I have a RecyclerView with several items types. It looks like this: 07/21/2017 Message 1 Message 2 Message 3 07/22/2017 Message 4 New messages header Message 5 Message 6 When new messages arrived I sort it by date and call notifyDataSetChanged() . It works well, but it automatically scroll my RecyclerView on new item(s) height. In this case I cannot use notifyItemInserted() because I don't know item position after sorting. How to force RecyclerView do not scroll after notifyDataSetChanged()

Visibility of expanding last view in the expandable RecyclerView

痴心易碎 提交于 2019-12-22 12:26:28
问题 I want the things in the last expandable item to be fully visible when it is clicked,Now what is happening means when I click on last item it expands down, but I manually need to scroll up again to see the the things inside the expanded item.How can the last expandable item be fully visible. I am using Recyclerview. 回答1: I have found the solution which I wanted, I used recyclerView.smoothScrollToPosition(selectedPosition); after setting the adapter. So now the things in the last expandable

Android scrolling function in cardView + RecyclerView layout

心已入冬 提交于 2019-12-22 12:22:29
问题 In my application I have first the cardview and then RecyclerView. Using my existing code I am able to scroll the whole page. But I want that I can also scroll only the card view items. Currently when I try to scroll cardview the complete layout is scrolled. My current code:- <android.support.design.widget.AppBarLayout android:id="@+id/app_bar_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true" android:theme="@style/ThemeOverlay

Android Create a Custom RecyclerView.Adapter and Create Other Class from it

主宰稳场 提交于 2019-12-22 11:24:05
问题 Well people I have a RecyclerView which I populate from a WebService, and I have a DataProvider class that manage the async requests. So when the data is fetched I need this DataProvider to inform the RecyclerView.Adapter that there is new data. For this I need to add a method to RecyclerView.Adapter that allow this communication. But When I create a base class (which extends RecyclerView.Adapter) with this new method in it, and then create the custom adapter it won't let me Override

Adding Dynamic Buttons to different layouts for phone and tablet using RecyclerView with GridLayoutManager

爷,独闯天下 提交于 2019-12-22 10:44:25
问题 I am adding dynamic buttons to a layout. Each button is added one at a time, and the layout must update itself if new buttons were added based on a user's action. So the layout could have 3 buttons, or 16, or whatever, depending on the user's action. And the buttons can be added at different times. So if the user opens the app and adds a button, then leaves and returns to the app and adds another button, the old one must remain. I want my buttons to be added, one by one, into a layout like

ListAdapter not refreshing RecyclerView if I submit the same list with different item order

风流意气都作罢 提交于 2019-12-22 10:32:19
问题 I am using a RecyclerView with ListAdapter (which uses AsyncListDiffer to calculate and animate changes when list is replaced). The problem is that if I submit() some list, then re-order that list, and submit() again, nothing happens. How do I force ListAdapter to evaluate this new list, even though it is "the same" (but order has changed)? New findings: I checked source code of submitList() and in the beggining there is a check: public void submitList(@Nullable final List<T> newList) { final

How to update Recyclerview data from another activity

橙三吉。 提交于 2019-12-22 09:56:03
问题 I have two activities MainActivity and Addlogactivity i am updating a data in Addlogactivity which should be displayed in mainactivity recyclerview the data is not updating in database MianActivityClass : public class MainActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor>{ RecyclerView recyclerView; Intent addDisplay; Mainrow_Adapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R

EditText loses focus on Scroll in RecyclerView

懵懂的女人 提交于 2019-12-22 08:31:31
问题 I have a RecyclerView which have EditText as its list items. When i scroll the RecyclerView , the EditText loses focus when the item goes off screen. So the focus does not remain on the EditText when it comes back on the screen on scroll. I want the focus to remain on the same item. For that i also tried storing position of the item on focus and reassigning the focus in onBindViewHolder . But that slow downs the scrolling. I also tried this with ListView but there is another kind of focus

GridLayout in Kotlin?

∥☆過路亽.° 提交于 2019-12-22 08:29:58
问题 I am trying to get a 2x6 (WxH) GridLayout in my Kotlin Android application. I have my xml and fragment / adapter set up for a RecyclerView but am a bit at a loss for as how to apply a GridLayout to this. How can I get my items (listview_row_enrollments.xml) to show in a grid instead of just a horizontal list? EnrollmentFragment.kt class EnrollmentsFragment : Fragment() { // TODO: Rename and change types of parameters private var mParam1: String? = null private var mParam2: String? = null

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