Java 安卓工作室可以';“找不到类”按钮

Java 安卓工作室可以';“找不到类”按钮,java,android,Java,Android,这是AndroidManifest.XML <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="activitytest.example.com.activitytest"> <application android:allowBackup="true" android

这是AndroidManifest.XML

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="activitytest.example.com.activitytest">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".FirstActivity"
        android:label="This is FirstActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>
错误在于:

Button button1 = (Button) findViewById(R.id.button_1);
找不到Button类,如何修复此问题? 这是First_layout.xml

<?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">
<Button
    android:id="@+id/button_1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Button_1" />


这是我第一次学习Android,请帮帮我。谢谢。

您的
FirstActivity
类中没有导入Android.widget.Button。

发生这种情况是因为您必须在
Activity
类中添加导入行。添加此行:

import android.widget.Button

你导入了班级按钮吗?
import android.widget.Button