意图和从字符串开始活动 [英] Intent and start activity from string
本文介绍了意图和从字符串开始活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个小问题.我想以其他方式开始活动.我知道
I have a little problem. I want to start activity but in something other way. I know that
Intent i = new Intent(this, ActivityTwo.class);
初始化意图,然后我可以startActivity
.但我想做这样的事情:
initialize intent and after that I can startActivity
. But I want do something like that:
Intent i = new Intent(this, MyString.class);
我没有nameActivity.class
,但是我想更改string.class.当我有班级的字符串名称时,如何开始活动?
I have no nameActivity.class
, but I want change on string.class. How I can start activity when I have string name of class?
推荐答案
尝试一下:
startActivity(this, Class.forName(yourStringClass));
这篇关于意图和从字符串开始活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文