Android “错误”;找不到显式活动类“;开始新活动时

Android “错误”;找不到显式活动类“;开始新活动时,android,Android,我正在尝试从另一个活动开始一个活动。最后,它不工作并且失败,错误为“找不到显式活动类”。到目前为止,我试图从前面的问题中找到一个解决方案,但我无法找到我问题的正确答案 这是我的密码 activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http

我正在尝试从另一个活动开始一个活动。最后,它不工作并且失败,错误为“找不到显式活动类”。到目前为止,我试图从前面的问题中找到一个解决方案,但我无法找到我问题的正确答案

这是我的密码

activity_main.xml

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="com.example.acer.explicitintent.MainActivity">

    <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Button" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</LinearLayout>
activity_two.xml

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="TextView" />
</LinearLayout>

感谢您的帮助。我是新来安卓的。

您没有在清单中定义您的
活动2
,这就是为什么您会出现此错误

在清单文件中定义您的
ActivityTwo

示例代码

 <application
        android:allowBackup="true"
        android:hardwareAccelerated="true"
        android:icon="@mipmap/ic_launcher"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:theme="@style/AppTheme.NoActionBar">
        <!-- Other code for your activities etc-->
        <activity
            android:name=".activity.ActivityTwo"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar"
            android:windowSoftInputMode="stateHidden" />

    </application>


您是否在清单中声明了
ActivityTwo
?请检查AndroidMenifest.xml文件是否可能重复是的,我没有在清单中声明“ActivityTwo.xml”。我不知道这件事。谢谢您的帮助。@chanu-r-sandepa请按照这些步骤进行操作,并让我知道您的问题是否得到了解决。谢谢你帮助我。我以前对此一无所知。再次感谢你。
    public class ActivityTwo extends AppCompatActivity {
    TextView textView;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_two);

        textView = (TextView)findViewById(R.id.tv);
        Bundle bundle = getIntent().getExtras();
        textView.setText(bundle.getString("value"));
    }
}
 <application
        android:allowBackup="true"
        android:hardwareAccelerated="true"
        android:icon="@mipmap/ic_launcher"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:theme="@style/AppTheme.NoActionBar">
        <!-- Other code for your activities etc-->
        <activity
            android:name=".activity.ActivityTwo"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar"
            android:windowSoftInputMode="stateHidden" />

    </application>