简体   繁体   English

如何在Android中使用标头来recyclerview

[英]How to use header to recyclerview in Android

In my application i want show some lists and for this i should use RecyclerView . 在我的应用程序中,我想显示一些列表,为此,我应该使用RecyclerView

I get this lists from server , you can see sample of my json in bottom : 我从服务器获得此列表,您可以在底部看到我的json示例:

{ 
     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 . 我想在title recyclerView中显示titledata:[] ,并在recyclerView显示data:[]data:[]

How can i it? 我该怎么办? Thanks guys <3 谢谢<3

Please help me 请帮我

You are going to have to look into RecyclerView adapters. 您将不得不研究RecyclerView适配器。

https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html 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) 要了解这一点,一个不错的教程是阅读Binpress指南(以下链接)。

https://www.binpress.com/tutorial/android-l-recyclerview-and-cardview-tutorial/156 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. 最近,我刚刚学习了如何将适配器绑定到视图,并放入视图,本教程对我们有很大帮助。

PS 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. 附言:您需要放置代码示例或对所要执行的操作提出直接问题,或者显示尝试的建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM