第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

單個(gè) ListView 中的不同對(duì)象

單個(gè) ListView 中的不同對(duì)象

慕尼黑8549860 2021-11-03 16:05:30
我有以下問題,我有 json 響應(yīng),其中包含 3 種不同的對(duì)象。我需要在一個(gè)列表視圖中顯示這些數(shù)據(jù)。我正在使用 GSON 庫來反序列化 JSON。json文件{"status": "success","data": {    "responses": [        {            "id": 3,            "status": 0,            "order": {                "id": 1,                "address": "3249-11-4910-0000, Burgaw, NC 28425, США",                "description": "работа работа ",                "created_at": 1535671020,                "status": 0,                "employer": {                    "id": 11,                    "name": "Test1",                    "surname": "TESTOVICH2",                    "phone": "777777777777",                    "email": "qwe@gmail.com",                    "photo": {                        "id": 11,                        "url": "http://link.com/storage/users/photos/a6e0ec9e4bf3e0b3ef0e2f06231169b0.png"                    }                }            },            "employee": {                "id": 11,                "name": "Test1",                "surname": "TESTOVICH2",                "phone": "777777777777",                "email": "qwe@gmail.com",                "photo": {                    "id": 11,                    "url": "http://link.com/storage/users/photos/a6e0ec9e4bf3e0b3ef0e2f06231169b0.png"                }            }        }              ],    "open_orders": [        {            "id": 2,            "address": "улица Шакарима, Алматы 050000, Казахстан",            "description": "пляжоажга",            "created_at": 1535676060,            "status": 0,            "employer": {                "id": 12,                "name": "юзер",                "surname": "юзер"            },                }            ]        }    ]}}
查看完整描述

2 回答

?
波斯汪

TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超4個(gè)贊

制作自定義的 Listview 并在元素的自定義布局中添加所有 3 個(gè)項(xiàng)目,假設(shè)您不想顯示某個(gè)特定元素中的所有項(xiàng)目,然后使用屬性使其不可見 visibility


查看完整回答
反對(duì) 回復(fù) 2021-11-03
?
青春有我

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超8個(gè)贊

首先我改變了布局。所以,最后,我在 1 個(gè)布局中放置了 3 個(gè) ListView。


<android.support.v4.widget.SwipeRefreshLayout

    android:id="@+id/swipe"

    android:layout_width="match_parent"

    android:layout_height="wrap_content">


    <android.support.v4.widget.NestedScrollView

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:fillViewport="true">


        <LinearLayout

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:orientation="vertical"

            android:padding="10dp">


            <ListView

                android:id="@+id/listviewResponse"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:divider="@android:color/transparent"

                android:dividerHeight="10sp"

                android:paddingStart="15dp"

                android:paddingEnd="15dp" />


            <ListView

                android:id="@+id/listviewDirect"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:divider="@android:color/transparent"

                android:dividerHeight="10sp"

                android:paddingStart="15dp"

                android:paddingEnd="15dp" />


            <ListView

                android:id="@+id/listviewOpen"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:divider="@android:color/transparent"

                android:dividerHeight="10sp"

                android:paddingStart="15dp"

                android:paddingEnd="15dp" />

        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

</android.support.v4.widget.SwipeRefreshLayout>

我創(chuàng)建了 3 個(gè)不同的適配器并將適配器設(shè)置為 Listviews


        @BindView(R.id.listviewResponse)

        ListView listViewResponse;

        @BindView(R.id.listviewOpen)

        ListView listViewOpen;

        @BindView(R.id.listviewDirect)

        ListView listViewDirect;


        private List<Response> responses = new ArrayList<>();

        private List<OpenOrder> open_orders = new ArrayList<>();

        private List<DirectOrder> direct_orders = new ArrayList<>();


        RequestListResponseAdapter adapterResponse;

        RequestListOpenAdapter adapterOpen;

        RequestListDirectAdapter adapterDirect;


        adapterResponse = new RequestListResponseAdapter(getContext(), responses);

        adapterOpen = new RequestListOpenAdapter(getContext(), open_orders, openType);

        adapterDirect = new RequestListDirectAdapter(getContext(), direct_orders);

        listViewResponse.setAdapter(adapterResponse);

        listViewDirect.setAdapter(adapterDirect);

        listViewOpen.setAdapter(adapterOpen);


查看完整回答
反對(duì) 回復(fù) 2021-11-03
  • 2 回答
  • 0 關(guān)注
  • 137 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)