我正在尝试将字符串转换为类名。 我的代码是:
app.actNum = "third.class";
in.close();
//on test
// Intent intent = new Intent(this.context,Class.forName(app.actNum));
Intent dialogIntent = new Intent(getBaseContext(), Class.forName(app.actNum));
但是得到
get ClassNotFoundException on Class.forName android
最佳答案
调用 Class.forName()
时,您应该使用不带扩展名的类名。因此,如果您的类 名为Test
并且位于package mypackage.tests
中,那么您应该使用:
Class.forName("mypackage.tests.Test")
关于android - 如何将字符串转换为类名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11168973/