的EditText软键盘"返回]钮 [英] EditText with soft keyboard and "Back" button

查看:100
本文介绍了的EditText软键盘"返回]钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用的EditText我有虚拟键盘。

When I'm using "EditText" I have the virtual keyboard.

pressing第一次后退按钮隐藏键盘。其次preSS调用我的活动onBack pressed回调。 OK,但是...

Pressing first time "Back" button hides the keyboard. Second press invokes "onBackPressed" callback in my activity. OK, but...

我不知道如何挂钩的第一preSS。我需要尽快虚拟键盘驳回处理输入数据。

I have no idea how to hook the very first press. I need to process input data as soon as the virtual keyboard dismissed.

任何想法是值得欢迎的。

Any ideas are welcome.

感谢。

推荐答案

在使用此方法键盘消失,您可以覆盖:

You can override when the keyboard disappears using this method:

  public boolean onKeyPreIme(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && 
       event.getAction() == KeyEvent.ACTION_UP) {
           // Do your thing here
           return false;
   }
   return super.dispatchKeyEvent(event);
  }

这是我其他的答案@摘自:<一href="http://stackoverflow.com/questions/6378259/android-error-popup-on-edittext-doesnt-move-down-when-keyboard-goes-away/6512220#6512220">Android:当键盘消失上的EditText错误弹出不向下移动。

Taken from my other answer @ : Android: Error popup on EditText doesn't move down when keyboard goes away.

这篇关于的EditText软键盘&QUOT;返回]钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆