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 btngps = FindViewById <Button>(Resource.Id.btngps); helper = new PrintHelper(); int err = 0; vid = FindViewById <EditText>(Resource.Id.vid); pid = FindViewById <EditText>(Resource.Id.pid); //查找USB设备 button.Click += (o, e) => { err = helper.IsOpen(); if (err != 1) { if (helper.Inite(this, Convert.ToInt32(1155), Convert.ToInt32(22304)) == 1) { helper.Open(); } //请求打印机状态 helper.PrinterState(); } Bitmap bm = BitmapFactory.DecodeStream(Resources.Assets.Open("Test4.png")); var res = helper.PrintImg(bm, 576, 1); if (res == 1) { res = helper.WalkPaper(6); if (res == 1) { res = helper.CutPage(); } //Log.Debug("print","打印成功"); } else { Log.Debug("print", res.ToString()); } }; //gps控制 btngps.Click += (o, e) => { //toggleGPS(); turnGPSOn(); }; ctx = this; }