当前位置: 首页 > 知识库问答 >
问题:

我从recylerview获取错误,因为我试图从sqlite获取数据并设置到recylerview

百里海超
2023-03-14
<?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 version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_baby_diapers"
    android:layout_width="match_parent"
    android:background="@color/colorNavIcon"
    android:layout_height="match_parent"
    tools:context="enkay.ntucsingapoor.Activity.BabyDiapers">


    <TextView
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:text="Search Bar"
        android:textSize="34dp"
        android:textStyle="bold"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="53dp"
        android:layout_marginTop="48dp"
        android:orientation="horizontal"
        >


        <Button
            android:layout_width="99dp"
            android:layout_marginLeft="279dp"
            android:layout_height="wrap_content"
            android:text="GO"
            android:background="@color/Yellow"
            />
    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="111dp">

   <android.support.v7.widget.RecyclerView
       android:id="@+id/List_items"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       >

   </android.support.v7.widget.RecyclerView>

    </LinearLayout>


</RelativeLayout>

共有1个答案

范翰池
2023-03-14

解决方案:

在setContentView中,

将r.layout.activity_baby diapers更改为r.layout.baby_diapers。并将您的两个xml,如item xml和mainactivity xml粘贴到问题中

 类似资料: