无法在 Activity 中引用 xml 布局

can't reference the xml layout in Activity

我遇到了一个问题,我设置了我创建的 activity.xml 的内容视图,但它显示了一些错误。请帮助我,我还在学习中。

这是创建 activity 时的图像

这是显示错误的图片

这是 xml 文件 activity_daily_expense_fragment_handler.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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="match_parent"
    tools:context=".daily_expense_fragment_handler">

</androidx.constraintlayout.widget.ConstraintLayout>

首先,您应该使用大写字母创建 class 的名称,例如:DailyExpenseFragmentHandler

然后检查您的导入。删除您的 R.imported 文件,然后单击布局,然后按 ALT + Enter 自动创建它。

请检查您导入的 R?如果您使用 android.R 导入,则使用您的包名称导入。