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

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

RecyclerView 在向下滾動(dòng)時(shí)崩潰(IndexOutOfBoundsException:)

RecyclerView 在向下滾動(dòng)時(shí)崩潰(IndexOutOfBoundsException:)

慕雪6442864 2023-06-21 14:49:20
我從 json 解析數(shù)據(jù)并將其傳遞給包含兩個(gè) Arraylist 的 ArrayList,然后將它們傳遞給 RecyclerView,RecyclerView 顯示數(shù)據(jù),但 1 項(xiàng)占用整個(gè)頁(yè)面,當(dāng)我向下滾動(dòng)時(shí),我可以看到第二項(xiàng),然后它崩潰了我嘗試了很多人的建議,讓父視圖或回收商的視圖 layout_heigt="wrap_content" 它甚至不會(huì)打開(kāi)頁(yè)面這里是回收商的視圖 xml(activity_resultsdwldview) 和 row.xml 其中包含每行的 cardview 設(shè)計(jì)如果這沒(méi)有組織或不清楚,請(qǐng)?jiān)徫?,我真的時(shí)間很短,而且是一個(gè)沒(méi)有太多經(jīng)驗(yàn)的初級(jí) android 開(kāi)發(fā)人員activity_resultsdwldview.xml<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="wrap_content"    tools:context=".Resultsdwldview">    <LinearLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        andoid:orientation="vertical">        <android.support.v7.widget.RecyclerView            android:id="@+id/recyvlerView"            android:layout_width="match_parent"            android:layout_height="match_parent" />    </LinearLayout></RelativeLayout>行.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical">    <android.support.v7.widget.CardView        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_marginStart="12dp"        android:layout_marginTop="12dp"        android:layout_marginEnd="12dp"        android:layout_marginBottom="12dp">        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:orientation="vertical">            <TextView                android:id="@+id/nameArray"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:textSize="20dp" />        </LinearLayout>    </android.support.v7.widget.CardView></LinearLayout>
查看完整描述

1 回答

?
素胚勾勒不出你

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

您的適配器的大小由以下各項(xiàng)設(shè)置:


 @Override

    public int getItemCount() {

            return Tests.size();

    }

并且您嘗試從以下位置獲取物品:


 @Override

    public void onBindViewHolder(@NonNull MainAdapter.ViewHolder holder, int i) {


        holder.URLName.setText( urlArray.get(i));

        holder.mFullname.setText( nameArray.get(i));



    }

您需要將適配器大小設(shè)置為您要檢索的大小:


 @Override

        public int getItemCount() {

               urlArray.size()

        }

或者


 @Override

    public int getItemCount() {

            return nameArray.sizes()

    }

我建議使用單個(gè)數(shù)組,或者可能是一個(gè)映射,以避免類似的問(wèn)題。


查看完整回答
反對(duì) 回復(fù) 2023-06-21
  • 1 回答
  • 0 關(guān)注
  • 269 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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