在我的應用程序中,我有一個活動(主要活動),其中有一個顯示片段的 ViewPager?,F在我有一個片段,里面有一個 RecyclerView。這個 RecyclerView 應該顯示“目標”對象列表。每次我運行該應用程序時,它都會崩潰,說它有一個空問題,我認為這可能是因為寫東西的順序。我試過然后更改順序,在互聯網上搜索其他可能的問題,但沒有成功。fragment_active_goals.xml:<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ActiveGoals"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/activeGoalsRecyclerView" android:layout_width="match_parent" android:layout_height="match_parent" /></FrameLayout>goals_list_item.xml:<?xml version="1.0" encoding="utf-8"?><androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/goalCardParent" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" app:cardCornerRadius="0dp" android:clickable="true" android:focusable="true" android:background="@color/cardview_light_background"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent"> <com.github.abdularis.civ.CircleImageView android:id="@+id/goalImage" android:layout_width="150dp" android:layout_height="0dp" app:layout_constraintDimensionRatio="1:1" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintVertical_bias="0.5" android:src="@drawable/active_brain_drawing"/>
RecycleViewAdapter 在加載它的項目時獲取 null 異常
慕田峪7331174
2023-02-23 10:50:47
