久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

硬鍵盤無法聚焦editText

Hard keyboard Fail to focus editText(硬鍵盤無法聚焦editText)
本文介紹了硬鍵盤無法聚焦editText的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個通用的 EditText.這很奇怪,因為我在使用硬鍵盤時無法對焦.上下文條件:

I have a common EditText. It's very strange because I can't focus it when use hard keyboard. Context condition:

  1. 打開 Droid 的硬鍵盤
  2. 開始活動
  3. 點擊editText輸入
  4. 輸入失敗.當您按任意鍵時,editText 會失去焦點.

要獲得焦點:按 Dpad,您將看到焦點從屏幕中的第一個小部件開始.最后關注目標EditText.然后就可以輸入了.沒有這個,你根本無法用硬鍵盤輸入.

To get focus: press Dpad and you will see the focus starts from the 1st widget in the screen. And finally focus on the target EditText. Then you can input. Without this, you can't input with hard keyboard at all.

軟鍵盤沒有這樣的焦點問題.

Soft keyboard doesn't have such focus problem.

我使用的是安卓 2.2.這是系統錯誤嗎?

I am using android 2.2. Is this a system bug?

推薦答案

如上所述,這顯然是硬鍵盤的錯誤.如果您的布局中有一個 EditText 和一個 TabHost,則在按下第一個鍵時,EditText 失去焦點并且按鍵被發送到活動.這是解決此問題的方法.在您的活動中實現這一點.

As mentioned above this is clearly a bug with hard keyboard. If you have an EditText and a TabHost in your layout, on first key pressed, EditText lose focus and key press is sent to the activity instead. Here is a work around to this problem. Implement this in your activity.

@Override

public boolean onKeyDown(int keyCode, KeyEvent event){

    final EditText myInputField = (EditText) findViewById(R.id.MyInputEditText);
    // this will happen on first key pressed on hard-keyboard only. Once myInputField 
    // gets the focus again, it will automatically receive further key presses.
    if (!myInputField.hasFocus()){ 
        myInputField.requestFocus();
        myInputField.onKeyDown(keyCode, event);
    }
    return super.onKeyDown(keyCode, event);
}

如果您有多個 EditText 字段,則需要在類變量中跟蹤當前聚焦的 EditText 并在 onKeyDown 方法中使用它.

if you have multiple EditText fields, you will need to keep track of currently focused EditText in a class variable and use it in onKeyDown method.

這篇關于硬鍵盤無法聚焦editText的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測向左或向右滑動?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉對話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設置為僅接受 Android 中的數值?)
主站蜘蛛池模板: 性高湖久久久久久久久 | 久久精品一区二区三区四区 | 欧美国产91 | 97人人爱| 先锋资源在线 | 日本xx视频免费观看 | 久久99深爱久久99精品 | 99精品久久久 | 免费在线看a | 欧美视频在线播放 | 成人区一区二区三区 | 51ⅴ精品国产91久久久久久 | 日韩欧美亚洲 | 精品熟人一区二区三区四区 | 免费的色网站 | 亚洲精品福利视频 | 九九九久久国产免费 | 国产电影一区二区在线观看 | 日韩视频中文字幕 | 伊人精品在线视频 | 黄色片在线网站 | 中文字幕一区在线观看视频 | 色综合久久天天综合网 | 欧美日韩久| 亚洲成人一区 | 性视频一区| 日韩在线视频免费观看 | 亚洲高清在线免费观看 | 亚洲精品久久久久中文字幕二区 | 亚洲综合在线一区 | 在线免费观看黄色 | 日韩在线欧美 | 国产精品久久久久久久久久软件 | 天天影视亚洲综合网 | 欧美日本亚洲 | 国产精品久久久久久久久久久久 | 久草福利| www.狠狠干 | av国产精品 | 久久一级大片 | a级黄色网 |