[英]Android: How to start an Activity from an alert dialog
I need to start an activity when the user chooses an item in an alert dialog. 当用户在警告对话框中选择一个项目时,我需要启动一个活动。 How do I get the context to pass to the intent constructor in the following code... 如何在上面的代码中将上下文传递给intent构造函数...
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Intent i = new Intent(<WHAT DO I PUT HERE?>, <new activity>.class);
startActivity(i);
}
});
Is it the use of the inner class?? 它是内部类的使用吗? Any thoughts? 有什么想法吗?
Intent i = new Intent("some.thing.activity");
startActivity(i);
//in the brackets you can add the activity path, ie: the package name //eg: za.ac.cut.Activity //在括号中可以添加活动路径,即:包名称//例如:za.ac.cut.Activity
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.