如何禁用早在安卓按钮 [英] how to disable back button in android
本文介绍了如何禁用早在安卓按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在做交换应用程序...我想禁用后退按钮。所以我用这个code ......并传递意图给它..
@覆盖
公共布尔的onkeydown(INT键code,KeyEvent的事件){
如果(键code == KeyEvent.KEY code_BACK和放大器;&安培; event.getRepeatCount()== 0){
//做一些事情就回来了。
返回true;
}
返回super.onKeyDown(键code,事件);
}
但在运行时,我preSS后退按钮在模拟器它更新活动,但是当我重新preSS后退按钮切换到仿真器的主页..请说明是他们的任何其他方法。
解决方案
@覆盖
公共无效onBack pressed(){
// 没做什么。
}
不返回true。只检查你的条件。
i am making swap application... i want to disable back button. so i use this code... and passed intent in to it..
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
// do something on back.
return true;
}
return super.onKeyDown(keyCode, event);
}
but while running when i press back button on emulator it updates activity but when i repress back button it switch to the home page of an emulator.. please suggest is their any other method
解决方案
@Override
public void onBackPressed() {
// do nothing.
}
do not return true. only check your conditions.
这篇关于如何禁用早在安卓按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文