【问题标题】:Display certain items from array of objects in recyclerview在 recyclerview 中显示对象数组中的某些项目
【发布时间】:2019-03-13 05:51:32
【问题描述】:

从下面的代码中,我想使用改造 2.0 在recyclerview 中显示request_idrequest_titlestatusno of trucks。如何做到这一点?

这是我的嵌套对象数组。

 [
        {
            "id": 96,
            "request_id": 24365,
            "request_title": "tsfghjjlfdsg;lhj",
            "transport_co_id": 1,
            "status": 1,
            "truck_info": [
                {
                    "driver_mobile": 2147483647,
                    "driver_name": "dsdsd",
                    "truck_no": 1111
                },
                {
                    "driver_mobile": 2147483647,
                    "driver_name": "add",
                    "truck_no": 727
                }
            ]
        },
        {
            "id": 97,
            "request_id": "test123",
            "request_title": "test title",
            "transport_co_id": 1,
            "status": 1,
            "truck_info": [
                {
                    "driver_mobile": 2147483647,
                    "driver_name": "dsdsd",
                    "truck_no": 1111
                },
                {
                    "driver_mobile": 2147483647,
                    "driver_name": "add",
                    "truck_no": 1
                }
            ]
         }   
    ]

【问题讨论】:

    标签: json object android-recyclerview nested retrofit2


    【解决方案1】:

    创建改造接口,类

    public class ChampApiClient {
    
        private static Retrofit retrofit = null;
    
        public static Retrofit getClient() {
            if (retrofit==null) {
                retrofit = new Retrofit.Builder()
                        .baseUrl(BASE_URL)
                        .addConverterFactory(GsonConverterFactory.create())
                        .build();
            }
            return retrofit;
        }
    
    }
    

    【讨论】:

    • 给我发电子邮件,我会向您发送工作代码 sumeethgowda2{at}gmail
    • 如果您需要 android 或 kotlin 中的任何内容,我们会为您提供帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-26
    • 2022-01-18
    • 2018-05-28
    • 2018-09-04
    • 1970-01-01
    • 2021-02-12
    • 1970-01-01
    相关资源
    最近更新 更多