简体   繁体   English

如何在ExEn中处理Android硬件后门按钮?

[英]How to Handle Android hardware backbutton in ExEn?

I am using Mono for Android and ExEn (thx for Andrew Russell). 我正在使用Mono for Android和ExEn(thx for Andrew Russell)。 I am not sure this question is specific to Mono for Android or more specific to ExEn. 我不确定这个问题是针对Android的Mono还是针对ExEn更具体的问题。 Anyway, I found only Java samples as a result of my searches. 无论如何,由于我的搜索,我发现只有Java样本。

I would like to implement a standard game menu navigation using the hardware back button. 我想使用硬件后退按钮实现标准游戏菜单导航。 Currently back button exits the application regardless the state of the gameplay or menu. 无论游戏玩法或菜单的状态如何,当前返回按钮都会退出应用程序。

Thx for answers. 谢谢答案。 -Horo -Horo

It is an Android specific question and you must override OnKeyDown method on your activity . 这是Android特定的问题,您必须在活动上覆盖OnKeyDown方法 Coding in Mono for Android: 用于Android的单声道编码:

public override bool OnKeyDown(Keycode keyCode, KeyEvent e)
{
  if (keyCode == Keycode.Back)
  {
    // your staff here:
    Toast.MakeText(this, "back!", ToastLength.Short).Show();

    return true;
  }

  return base.OnKeyDown(keyCode, e);
}

Remember to return "true" after your code to indicate you have handled the event. 请记住在代码后返回“true”表示您已处理该事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Xamarin Shell - 硬件后退按钮 - Xamarin Shell - Hardware backbutton Xamarin Android:处理微调框下拉列表中的硬件密钥 - Xamarin Android: Handle Hardware Key in Spinner Dropdown 如何检测Android设备中的硬件键盘? - How detect if hardware keyboard in Android devices? XAMARIN:如何将[Android]硬件后退按钮链接到Webkit.WebView? - XAMARIN: How to Link [Android] Hardware Back Button to Webkit.WebView? 如何在Xamarin.Android中拦截硬件键盘按钮? - How to intercept Hardware Keyboard Buttons in Xamarin.Android? 如何在Xamarin Android中隐藏“硬件”菜单按钮中的溢出图标 - How to Hide the overflow icon in Hardware menu button in Xamarin Android 如何编写代码以使用XAMARIN中的USB电缆将硬件设备连接到Android移动设备 - How to write code to connect a hardware device to Android mobile using USB cable in XAMARIN 如何在 Xamarin Android 应用程序中添加对 Amazon Fire TV 远程控制硬件的支持? - How to Add Support For the Amazon Fire TV Remote Control Hardware in a Xamarin Android App? 如何在Xamarin Android项目中处理多个应用程序类 - How do you handle multiple application classes in a xamarin android project 如何在Xamarin Android中处理回收站视图项内的按钮单击? - How to handle button click inside recycler view item in Xamarin Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM