[英]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.