android-recyclerview

How to implement scrolling in RecyclerView on Android TV?

三世轮回 提交于 2019-12-21 17:01:59
问题 I have an application which I need adapt for Android TV. This application contains horizontal RecyclerView and it doesn't scroll when I press D-pad buttons on remote control. I found this solution, but it crashes. Here is the code: <ru.myapp.package.HorizontalPersistentFocusWrapper android:layout_width="wrap_content" android:layout_height="wrap_content"> <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:layout_width="match_parent" android:layout_height="250dp"

How to force RecyclerView to scroll when there's not enough items to fill the height of the screen

亡梦爱人 提交于 2019-12-21 13:08:27
问题 I made a RecyclerView inside a NavigationView with a custom first item as an equivalent to ListView's addHeaderView() . On the bottom part of that header layout I placed an EditText so that I can filter out the list below. What I wanted to do was to scroll the RecyclerView all the way up until the EditText would be the topmost item whenever the EditText gains focus. However if my item count is small enough that it wouldn't be able to fill-up the entire height of the NavigationView, the

Android TV move focus between RecyclerViews

大憨熊 提交于 2019-12-21 12:59:59
问题 I am building an Android TV app with the following layout: Both lists on the left and on the right are RecyclerViews with vertical LinearLayoutManagers, Header view is static. Navigation with D-PAD works fine within one list, but when switching from one list to another there are issues. Focus moves from, say list1's item 5 to list2' item 5. When list 2 is short has less than 5 items, it just loses focus. I want the last focused item index saved and when the user navigates list1-list2-list1

Generate and set random colors on text view background within Recycler View in Android

青春壹個敷衍的年華 提交于 2019-12-21 12:54:42
问题 I am Trying to Generate Random Colors and set the Random color as background of Text View Just Like in GMail app. The Text view is Having a circular background initially set in xml which i have done using shape. I have done some research and used some code available on internet but the changes are not reflecting in my app. Below is my Recycler View Adapter Class: public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.Items> { ArrayList<GmailDataHolder> data; Context

RecyclerView with background image at top

耗尽温柔 提交于 2019-12-21 12:22:14
问题 What I'm trying to achieve is this: As you can see, there is a background image that appears slightly behind the first card in the RecyclerView. When the user scrolls, the background image, as well as the "Discover" text and icon, should also scroll off the screen. I've looked into putting the RecyclerView into a NestedScrollView , but from what I've read, this breaks the RecyclerView and doesn't allow it to recycle views (I could be wrong). How would I achieve something like this? Right now,

RecyclerView number of visible items

独自空忆成欢 提交于 2019-12-21 11:29:10
问题 I am creating a horisontal RecyclerView in my app. It has to show 2 images on the screen at a time (so width of each image has to be 50% of the screen). For now it works fine but each item consums all width of the screen. Here is my code mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_main_ads); LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(getActivity()); mLinearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); mRecyclerView.setLayoutManager

Where should I place setOnClickListener in a RecyclerView Adapter

此生再无相见时 提交于 2019-12-21 09:24:59
问题 In tutorials on internet where they setOnClickListener in Adapter of RecyclerView they define it in two ways : either inside ViewHolder or inside BindViewHolder. My Question is which one is a better approach, Please recommend any another approach if available 1) inside ViewHolder: public static class ViewHolder extends RecyclerView.ViewHolder { public ViewHolder(View itemView) { super(itemView); tvSrc = (TextView) itemView.findViewById(R.id.tvSrc); itemView.setOnClickListener(new View

Room Invalidation tracker is initialized twice

本小妞迷上赌 提交于 2019-12-21 09:14:43
问题 I have a horizontal recycler view with custom items in it . Each item can hold the position of current item in the Recycler view . I want to update the item position when item is moved using drag and drop . However the data is getting deleted when there are more then three items in horizontal view.Please Help me out . Source Code This is what i am getting in Logcat: E/ROOM: Invalidation tracker is initialized twice :/. E/Item moved: Counterfrom3 next item:to2 Initialization of database in

SQLite data to a RecyclerView

与世无争的帅哥 提交于 2019-12-21 09:14:36
问题 The app has data in a SQLite database. The UI is primarily a RecyclerView. The question is how to best to transfer data from the database into the UI, whilst keeping off the main thread? I originally planned to use a CursorLoader, ContentProvider, and RecyclerView. But reading around it looks like RecyclerView has no out-of-the-box support for Cursor-supplied data. Dang. That then leaves me with a few other options... AsyncTask to load the data, put it into model objects, and pass into the

AppBarLayout, NestedScrollView, FrameLayout, what is the deal?

你说的曾经没有我的故事 提交于 2019-12-21 09:09:51
问题 I have the following code in my activity: <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="160dp"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed">