linearlayoutmanager

RecyclerView scroll to position and get that view

核能气质少年 提交于 2019-12-13 01:28:35
问题 I want to auto scroll a list item to top (firstVisible item) in my recycler view and get the view at that position, so I can highlight it, from my fragment. So, this is the gist of my fragment code : private void activateNewListItem(int position) { mLayoutManager().scrollToPositionWithOffset(position, 0); RecyclerView.ViewHolder viewHolder = mRecyclerView.findViewHolderForLayoutPosition(position); View view = viewHolder.getItemView(); view.setBackgroundColor(getResources().getColor(R.color

RecyclerView with null pointer exception

烈酒焚心 提交于 2019-12-13 00:55:17
问题 I am getting some news data from my CMS,and want to display them in a RecyclerView.The problem is that I am getting a null pointer exception in the line where I using the LinearLayoutManager. Here is the logcat output. Caused by: java.lang.NullPointerException at testing.theo.manchesterunitedapp.newsandfeatures.FeaturesFragment.onCreateView(FeaturesFragment.java:65) at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962) at android.support.v4.app.FragmentManagerImpl

Android: restore RecyclerView item positions after app re-opens

寵の児 提交于 2019-12-06 14:54:06
I have a RecyclerView list of CardView items. I save CardView data to a SQLite database. The user can drag CardViews up and down in the list to change the order of the items. When the user exits the app, I'd like to save the current order of the RecyclerView items. Then when the user re-opens the app, I'd like to restore that exact order of the RecyclerView items. I have tried multiple approaches based on other SO posts with no luck: -- How to save RecyclerView's scroll position using RecyclerView.State? -- RecyclerView store / restore state between activities -- How to save scroll position of

RecyclerView LinearLayout manager always returns -1 in landscape mode - findLastCompletelyVisibleItemPosition()

烈酒焚心 提交于 2019-12-06 01:49:27
问题 I'm using findLastCompletelyVisibleItemPosition() to determine the last visible item in my RecyclerView. Here is a code snippet of how I'm setting up my layout: mRecyclerView.setHasFixedSize(true); LinearLayoutManager mLayoutManager = new LinearLayoutManager(getContext()); mRecyclerView.setLayoutManager(mLayoutManager); Layout XML: <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/swipe_container" android:layout_width=

RecyclerView items lose focus

巧了我就是萌 提交于 2019-12-05 00:14:59
问题 In my fire tv app I'm using a recyclerview with horizontal layout . Scrolling with dpad works and also items are gaining focus. But when I hold the button it scrolls very fast because many keydown events are triggered, and items are losing their focus and it's not possible to scroll anymore because another Textview above my recyclerview is gaining the focus. It looks like a bug. Is there any workaround for this? 回答1: I face the same problem, what i do in my project likes below in my Activity

layoutmanager.FindFirstCompletelyVisibleItemPosition always returns -1

廉价感情. 提交于 2019-12-04 05:08:57
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); var onScrollListener = new XamarinRecyclerViewOnScrollListener(Activity, layoutmanager, adapter); The

RecyclerView items lose focus

人走茶凉 提交于 2019-12-03 15:31:41
In my fire tv app I'm using a recyclerview with horizontal layout . Scrolling with dpad works and also items are gaining focus. But when I hold the button it scrolls very fast because many keydown events are triggered, and items are losing their focus and it's not possible to scroll anymore because another Textview above my recyclerview is gaining the focus. It looks like a bug. Is there any workaround for this? I face the same problem, what i do in my project likes below in my Activity (containing RecyclerView): private long mLastKeyDownTime = 0; @Override public boolean onKeyDown(int keyCode

How to scroll to a particular position in recyclerview inside scrollview?

谁都会走 提交于 2019-12-02 23:36:44
I have searched a lot regarding my query and none of them was useful. I have a recyclerview and some static data inside a scroll view which is inside a root parentlayout as show below. I have set - scrollview.scrollto(0,0); because everytime i open the activity it jumps to the recyclerview firstitem and it skips out the static data above the recyclerview. recyclerview.setNestedScrollingEnabled(false); recyclerview.setfocusable(false); for smoothscroll. the problem is with- layoutmanager.scrollToPositionWithOffset(pos,0); it is not working. I have set the aboveline after setting adapter to

Start my RecyclerView Horizontal Carousel from the center item

橙三吉。 提交于 2019-12-01 05:03:01
问题 I'm creating a carousel Horizontal RecyclerView with Zoom on focused item that is starting from the first item of the RecyclerView. Code for custom CenterZoomLayoutManager: public class CenterZoomLayoutManager extends LinearLayoutManager { private final float mShrinkAmount = 0.15f; private final float mShrinkDistance = 0.9f; public CenterZoomLayoutManager(Context context, int orientation, boolean reverseLayout) { super(context, orientation, reverseLayout); } @Override public int

How to change position of items in RecyclerView programmatically?

纵饮孤独 提交于 2019-11-30 16:06:24
问题 Is there a way to move a specific item to a specific position in RecyclerView using LinearLayoutManager programmatically? 回答1: You can do this: Some Activity/Fragment/Whatever: List<String> dataset = new ArrayList<>(); RecyclerView recyclervSomething; LinearLayoutManager lManager; MyAdapter adapter; //populate dataset, instantiate recyclerview, adapter and layoutmanager recyclervSomething.setAdapter(adapter); recyclervSomething.setLayoutManager(lManager); adapter.setDataset(dataset);