[英]alertDialog button go to URI
As the title says, I want to make a button in my alertDialog of my app go to a certain URI, and I was wondering how i would do this? 如标题所述,我想在我的应用程序的alertDialog中使一个按钮转到某个URI,我想知道我该怎么做?
heres and excerpt of the code: 代码的继承人和摘录:
// 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();
instead of making display the toast info saying the button is broke, I actually want it to launch the browser and take the user to a URI. 我实际上不想让它显示吐司信息说按钮坏了,而是希望它启动浏览器并将用户带到URI。
There has to be a way... 一定有办法...
Ideas? 有想法吗?
Thanks! 谢谢!
Updated with more code.. 更新了更多代码。
Start intent in onClick()
handler: 在
onClick()
处理程序中启动意图:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("http://website.com"));
startActivity(intent);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.