我已经搜索了如何从另一个 Activity 开始和 Activity,我一直在寻找
Intent intent = new Intent(this, ExampleClass.class); 启动 Activity ( Intent );
但我想从一个实例化的 Activity 开始。我有一个包含许多 Activity 的容器,当用户从我的 UI 中选择时,我希望显示一个特定的 Activity 。
所以,例如。
class MyExample extends Activity {
MyExample mx = new MyExample();
那么我现在该如何开始这个 Activity。
我想要的是
Intent intent = new Intent(this, mx);
startActivity(intent);
非常感谢经验丰富但刚接触 Android 的 Java 开发人员的任何帮助。
最佳答案
这是可能的,虽然我还不明白你为什么要这样做。
确保您要启动的 Activity
已在您的 list 中正确声明:
<activity android:name=".com.example.MyExample" ... />
然后你可以调用你当前的 Activity :
Intent myIntent = new Intent();
myIntent.setComponent(new ComponentName("com.example", "com.example.MyExample"));
startActivity(myIntent);
关于android - 在没有 .class 的情况下开始 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15849709/