0
我想設置類的意圖到字符串值中列出的地址,以便我可以啓動給定的活動。該字符串在運行時動態組合。如何從字符串值設置意圖的類?
反正有做類似下面運行代碼:
String target=com.test.activity1.class;
Intent intent=new intent();
intent.setClass(this, target);
感謝
我想設置類的意圖到字符串值中列出的地址,以便我可以啓動給定的活動。該字符串在運行時動態組合。如何從字符串值設置意圖的類?
反正有做類似下面運行代碼:
String target=com.test.activity1.class;
Intent intent=new intent();
intent.setClass(this, target);
感謝
你可以嘗試使用forName
method of the Class
class。
不管怎樣,我一直在想使用setClassName
方法......它可能是你的情況可能是有用
意圖類有方法setClassName
Intent intent = new Intent().setClassName(context,target);