Dr KoKo
Dr KoKo

Reputation: 21

How to use header to recyclerview in Android

In my application i want show some lists and for this i should use RecyclerView.

I get this lists from server, you can see sample of my json in bottom :

{ 
     result:[
            list1:{
            title:title1,
            data:[
            {
                id:1,
                name:name1_list1
            },
            {
                id:2,
                name:name1_list2
            },
            {
                id:3,
                name:name1_list3
            }
            ]
        },
            list2:{
            title:title2,
            data:[
            {
                id:2-1,
                name:name2_list1
            },
            {
                id:2-2,
                name:name2_list2
            }
            ]
        },
            list3:{
            title:title3,
            data:[
            {
                id:3-1,
                name:name3_list1
            },
            {
                id:3-2,
                name:name3_list2
            },
            {
                id:3-3,
                name:name3_list3
            },
            {
                id:3-4,
                name:name3_list4
            }
            ]
        }
]}

I want show data of title into recyclerView of title, and show data of data:[] in recyclerView.

How can i it? Thanks guys <3

Please help me

Upvotes: 0

Views: 116

Answers (1)

Vaughan D
Vaughan D

Reputation: 149

You are going to have to look into RecyclerView adapters.

https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html

These are then pushed into the layout (which you create) think of the layout as a placeholder for the data, but you need to program the new data that comes into into the adapter.
A good tutorial to learn this is have a read on Binpress Guide to (link below)

https://www.binpress.com/tutorial/android-l-recyclerview-and-cardview-tutorial/156

I have recently just learned how to tie adapters to views, and put in views and this tutorial helped out a lot.

P.S word of advice you need to place code examples or direct questions on what you are trying to do, or show an attempt of trying it.

Upvotes: 1

Related Questions