亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我從 recylerview 得到錯誤,因為我試圖從 sqlite 獲取數據并設置到

我從 recylerview 得到錯誤,因為我試圖從 sqlite 獲取數據并設置到

大話西游666 2021-09-03 10:29:19
09-06 15:12:57.845 25003-25003/enkay.ntucsingapoor E/AndroidRuntime:致命異常:主進程:enkay.ntucsingapoor,PID:25003 java.lang.RuntimeException:無法啟動活動ntucsingapoor.Activity.BabyDiapers}:java.lang.NullPointerException:嘗試在空對象引用上調用虛方法“void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager)”在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) 在 java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main( ZygoteInit.java:767) 引起:java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager)' on a null enkay.ntucsingapoor.Activity.BabyDiapers 中的對象引用。onCreate(BabyDiapers.java:55) at android.app.Activity.performCreate(Activity.java:6975) at 這是我的 Xml 文件 MArket_Recyler<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical" android:layout_width="match_parent"    android:layout_height="match_parent">    <android.support.v7.widget.RecyclerView        android:id="@+id/recyler_data"        android:visibility="gone"        android:layout_width="match_parent"        android:layout_height="wrap_content"        >    </android.support.v7.widget.RecyclerView></LinearLayout>這是我的另一個 xml 文件
查看完整描述

1 回答

?
九州編程

TA貢獻1785條經驗 獲得超4個贊

解決方案:

在您的 setContentView 中,

將 R.layout.activity_baby 尿布更改為 R.layout.baby_diapers。并將您的兩個 xml 粘貼到問題中,例如 item xml 和 mainactivity xml

就是這樣


查看完整回答
反對 回復 2021-09-03
  • 1 回答
  • 0 關注
  • 222 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號