【发布时间】:2011-11-23 02:50:48
【问题描述】:
正如标题所说,我想让我的应用程序的 alertDialog 中的一个按钮转到某个 URI,我想知道我该怎么做?
这里和摘录的代码:
// Add a neutral button to the alert box AND assign a listener for said button...
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener(){
// click listener for box
public void onClick(DialogInterface arg0, int arg1){
// Button was clicked!!
Toast.makeText(getApplicationContext(), "Dialog closed successfully!", Toast.LENGTH_LONG).show();
}
});
// Add a Forums button to take user to forums...
alertbox.setPositiveButton("Forums", new DialogInterface.OnClickListener(){
//listener for button
public void onClick(DialogInterface arg0, int arg1){
// Button Pressed!
Toast.makeText(getApplicationContext(), "Oops...this button is broke!", Toast.LENGTH_LONG).show();
}
});
// show it!!!
alertbox.show();
我实际上希望它启动浏览器并将用户带到一个 URI,而不是显示按钮已损坏的 toast 信息。
一定有办法……
想法?
谢谢!
更新了更多代码..
【问题讨论】:
标签: java android hyperlink android-alertdialog