我使用Xamarin并在Android设备上进行调试。
如何在Xamarin.Forms中重定向url?
我是在默认页面加载时尝试这个的。
发布于 2016-04-19 10:42:40
您可以使用Device.OpenUri
在移动浏览器中打开URL:
Device.OpenUri(new Uri("http://xamarin.com"));
下面是一个示例实现:
using System;
using Xamarin.Forms;
namespace Example
{
class MyPage : ContentPage
{
public MyPage()
{
Button button = new Button
{
Text = "Open URL",
Font = Font.SystemFontOfSize(NamedSize.Large),
BorderWidth = 1,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
button.Clicked += OnButtonClicked;
this.Content = new StackLayout
{
Children = {
button
}
};
}
void OnButtonClicked(object sender, EventArgs e)
{
Device.OpenUri(new Uri("http://xamarin.com"));
}
}
}
https://stackoverflow.com/questions/36715730
复制相似问题