kandi X-RAY | RecyclerView-Kotlin Summary
kandi X-RAY | RecyclerView-Kotlin Summary
RecyclerView-Kotlin
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of RecyclerView-Kotlin
RecyclerView-Kotlin Key Features
RecyclerView-Kotlin Examples and Code Snippets
Community Discussions
Trending Discussions on RecyclerView-Kotlin
QUESTION
I have a nested recyclerview which should look like in the .
I implemented it according to this helpful site.
The problem is, that I sometimes have a user with hundreds of items and in that case, it takes half a minute to open the activity.
I have a room database in the backend with two linked tables with foreign keys (users and items) and I select all users to get a user/item list where the items are a list in the user-table.
class userWithItems: (id: Int, name: String, ... ,List)
and I create the inner recycler view with the List of items in the adapter.
Would it be better to make one List UserItems (userid:Int, username:String, ... itemid:Int, itemList) and group them for the outer rv.
Or is there a possibility to get rid of the nested rv and make the design with just one recyclerview-list?
Or is there another solution to make the nested recyclerview work even if there are many items for a user?
code for the adapters:
...ANSWER
Answered 2018-Nov-30 at 11:36E. Reuter i have been through this situation the thing is the approach is quite correct by using nested Recycler View. Your code seems to be good. but the queries which you are using to query database. I think you should use queries in Background or on the other threas and show result as you get them instead of querying it from OnCreate or from main thread. Because getting this many items in one go can possibly create lag to activity and decreasing performance. try this out if you have not yet and let me know. What happens. Thanks...
I am editing my answer. the other thing you could do is if you have more than certain amount of items then instead of getting them at the first you should use some thing like pagination to load certain amount of items at once to avoid this lag.
Here i am attaching the code to query certain amount of data per load....
QUESTION
We are trying to design a nested recyclerview we get the idea that TWO adapters are used. What we are not understanding is the data source construction. We are using SQLite DB for a data source. Our design is a Parent text field that describes a Department in a grocery store. Like Produce and Liquor with child Items in these Depts being tomatoes avocados and beer.
If we use two Models and two DB Tables how do we associate the child items with the Departments?
We thought about one DB Table with this format record 1 Produce tomatoes record 2 null avocado record 3 Liquor beer. This seems not so smart. So next we thought about JOINS or UNION call to make one new Table out of our two tables one with Dept and the other Items.
How would we lay out the two tables so they associate items with respective departments?
We are also guessing here that our ViewHolder needs to be a Class of its own that talks to the Parent and Child Adapters.
We will post a photo of the design we are trying to emulate (copy)
Our questions are how to design the DB Tables?
Do we need a ViewHolder Class that interfaces with the two Adapters?
How to create the two tables and what type of JOIN to call to make a new table?
We have looked at this link and the idea is great but his code does not have the same data source. One is date the other could be SQLite Kotlin Nested
OK we have a working DB and the Two Adapters DeptAdapter and ItemAdapter work BUT not at the same time. The two tables DEPT_TABLE and ITEM_TABLE have data
The view for the two tables is displayed in ListActivity with a activity_list.xml
The ListActivity CAN NOT provided both table views at one time
What we think is wrong is the recyclerview declared in recyclerview_dept.xml is not involved and all the work or views are being provided by the recyclerview in the activity_list.xml with id rvListActivity
code posted below with ONE QUESTION
...ANSWER
Answered 2018-Sep-27 at 23:12So this is really slick code. One issue I have not tied it to a SQLite DB yet.
When I get time to hook it up to a DB I will post an update.
You had a number of the ides correct two adapters is a must
And the List in a List is used here by adding the ChildModel to the ParentModel as a List
This code belongs to Navendra Jha
You will need to do a little manipulation as he thought it would be fun to have the children scroll left and right independent of the parent so in the MainActivity which displays the data change this line from horizontal to vertical
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install RecyclerView-Kotlin
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page