mono for android读书笔记之真机调试

调试环境

1.软件:monodevelop v3.0.3.5

2.硬件:华为C8650s手机一部,数据线一根,thinkpad e420笔记本电脑一台

调试的应用程序有一个Activity,Activity上有一个按钮,按钮的caption会记录按钮的点击次数。

测试程序如下:

using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; namespace AndroidApplication2 { [Activity(Label = "AndroidApplication2", MainLauncher = true, Icon = "@drawable/icon")] public class Activity1 : Activity { int count = 1; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById<Button>(Resource.Id.MyButton); button.Click += HandleClick; } void HandleClick (object sender, EventArgs e) { Button button = FindViewById<Button>(Resource.Id.MyButton); button.Text = string.Format("{0} clicks!", count++); } } }

在monodevelop上编译:build->build all.

连上手机,开始调试:运行->Start Debugging->选择device->点击OK

等待程序下载到手机后,在程序中HandleClick 函数内下断点。手机上开始运行应用,点击按钮,程序会断在断点处,如下图所示。

mono for android读书笔记之真机调试_第1张图片

mono for android读书笔记之真机调试_第2张图片

你可能感兴趣的:(android)