linearlayoutmanager

IndexOutOfBoundException with RecyclerView

谁都会走 提交于 2020-12-06 23:56:32
问题 I am experiencing a problem with my application. I am getting a java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder and not only on Samsung device but also on LG because I have read somewhere that this exception only happens on Samsung device. My solution was to make my own LinerLayoutManager and to catch the exception in onLayoutChildren() method. After implementing this solution the exception doesn't occur very often like before but

RecyclerView - Scroll To Position Not Working Every Time

守給你的承諾、 提交于 2020-06-09 11:47:24
问题 I have implemented a horizontal scrollable RecyclerView . My RecyclerView uses a LinearLayoutManager , and the problem I am facing is that when I try to use scrollToPosition(position) or smoothScrollToPosition(position) or from LinearLayoutManager 's scrollToPositionWithOffset(position) . Neither works for me. Either a scroll call doesn't scroll to the desired location or it doesn't invoke the OnScrollListener . So far I have tried so many different combinations of code that I cannot post

How to preset the number of the items(or the percent of the item) that is showing on the screen at a time in HorizontalRecyclerView?

走远了吗. 提交于 2020-01-25 06:41:49
问题 I have HorizontalRecyclerView with images that is being stored locally in Resource. The size of the image is 262dp x 150dp (SVGs). I want to show 1.5 items at a time on the screen. 1 full Image and the other is 0.5 times. I have achieved it by manipulating the width of the item in oncreateviewholder() of the recyclerview like below: int itemWidth = (int)(width / 1.5); ViewGroup.LayoutParams layoutParams = ((BannerHolder) holder).bannerImg.getLayoutParams(); layoutParams.height = layoutParams

RecyclerView scroll to position when a new item is added

风格不统一 提交于 2020-01-13 07:51:11
问题 I want my RecyclerView to scroll to the bottom when a new item is added to the list. Below is my code: RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity()); recyclerView.setLayoutManager(layoutManager); adapter = new RecyclerViewAdapter(data, recyclerView); recyclerView.setAdapter(adapter); And when I click a button which is below the RecyclerView , data is added to the list: public void addNewCard() { data.add("New"); adapter.notifyItemInserted(data.size() - 1);

RecyclerView scroll to position when a new item is added

送分小仙女□ 提交于 2020-01-13 07:51:08
问题 I want my RecyclerView to scroll to the bottom when a new item is added to the list. Below is my code: RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity()); recyclerView.setLayoutManager(layoutManager); adapter = new RecyclerViewAdapter(data, recyclerView); recyclerView.setAdapter(adapter); And when I click a button which is below the RecyclerView , data is added to the list: public void addNewCard() { data.add("New"); adapter.notifyItemInserted(data.size() - 1);

layoutmanager.FindFirstCompletelyVisibleItemPosition always returns -1

感情迁移 提交于 2020-01-12 17:24:01
问题 I have a recyclerview in my android project which displays media contents within each view. What I'm trying to achieve is that I'm able to play/pause media as I scroll up and down. I need to get the adapter position of the completely visible view. I'm doing something like this. In my activity fragment I have this: layoutmanager = new LinearLayoutManager(Activity); adapter = new FeedAdapter(vid, userName, this.Context); feeditem.SetLayoutManager(layoutmanager); feeditem.SetAdapter(adapter);

layoutmanager.FindFirstCompletelyVisibleItemPosition always returns -1

帅比萌擦擦* 提交于 2020-01-12 17:23:30
问题 I have a recyclerview in my android project which displays media contents within each view. What I'm trying to achieve is that I'm able to play/pause media as I scroll up and down. I need to get the adapter position of the completely visible view. I'm doing something like this. In my activity fragment I have this: layoutmanager = new LinearLayoutManager(Activity); adapter = new FeedAdapter(vid, userName, this.Context); feeditem.SetLayoutManager(layoutmanager); feeditem.SetAdapter(adapter);

how to get LinearLayoutManager from RecyclerView..?

时间秒杀一切 提交于 2020-01-07 02:26:27
问题 so I had my RecyclerView In fragment tab, as usual using LinearLayoutManager and I also want to use for Endless scroll ScrollListener ,the problem is if I make a variable LinearLayoutManager in OnCreate method as below public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); mLayoutManager = new LinearLayoutManager(Context); } public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View row = inflater

Horizontally center first item of RecyclerView

亡梦爱人 提交于 2019-12-30 03:21:05
问题 I want to use a RecyclerView to emulate the behavior of a MultiViewPager , in particular I'd like to have the selected item at the center of the screen, including the first and the last element . As you can see in this image, the first item is centered and this would be my expected result. What I did was to setup a RecyclerView with an horizontal LinearLayoutManager and a LinearSnapHelper . The problem with this solution is that the first and the last item will never be horizontally centered

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