intent.button.Click += delegate {
var uri = Android.Net.Uri.Parse ("http://www.xamarin.com");
var intent = new Intent (Intent.ActionView, uri);
StartActivity (intent);
};
var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += (s, e) => {
// your code goes here
};
stackP.GestureRecognizers.Add(tapGestureRecognizer);
2 回答
1.)创建一个新的Xamarin.Android应用程序 . 项目模板将创建一个名为Activity1(MainActivity.cs)的活动,其中包含一个按钮 .
2.)从MainActivity.cs中的button.Click处理程序,创建一个Uri和一个Intent .
希望它会对你有所帮助
您可以将
TapGestureRecognizer
添加到任何控件 . 在这种情况下,假设您的主容器是StackPanel . 点击它时,您可以执行任何操作,例如,打开URL . 请阅读如何操作here .基本上:
有关GestureRecognizers的更多信息,请参阅official documentation .