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

onEditorAction() 中的 null keyevent 和 actionid = 0 (Jelly

null keyevent and actionid = 0 in onEditorAction() (Jelly Bean / Nexus 7)(onEditorAction() 中的 null keyevent 和 actionid = 0 (Jelly Bean/Nexus 7))
本文介紹了onEditorAction() 中的 null keyevent 和 actionid = 0 (Jelly Bean/Nexus 7)的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有一個(gè)編輯文本,它在我的應(yīng)用程序中用作搜索框.在我的 Nexus 7 上的 Jelly Bean 中,當(dāng)我在我正在收聽的文本框中輸入一些內(nèi)容并點(diǎn)擊輸入 KeyEvent = null 和 ActionId = 0 傳遞給 onEditorAction() 方法.有人遇到過這種情況么?我認(rèn)為這可能是一個(gè)錯(cuò)誤.

I have an edit text which functions as a search box in my application. In Jelly Bean on my Nexus 7 when I type something into the text box which I am listening on and hit enter the KeyEvent = null and ActionId = 0 passed into the onEditorAction() method. Has anyone else encountered this? I'm thinking it might be a bug.

在下面的第二個(gè) if 語句中,我得到一個(gè)空指針,因?yàn)?actionId = 0 和 KeyEvent = null;

In the second if statement below I get a null pointer because the actionId = 0 and KeyEvent = null;

// Search field logic.
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    Log.d(TAG, "onEditorAction");
    if (event != null && event.getAction() != KeyEvent.ACTION_DOWN)
        return false;
    if (actionId == EditorInfo.IME_ACTION_SEARCH
            || event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
              .....Do some stuff();
     }
}

推薦答案

最終添加了對(duì) KeyEvent 的空檢查.感謝 commonsware 指出這發(fā)生在 3.0+ 上.看起來更像是一種解決方法而不是解決方案,但它確實(shí)有效.

Ended up adding in a null check for KeyEvent. Thanks to commonsware for pointing out this happens on 3.0+. Seems more like a workaround then a solution, but it works.

// Search field logic.
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    Log.d(TAG, "onEditorAction");
    if (event != null && event.getAction() != KeyEvent.ACTION_DOWN) {
        return false;
    } else if (actionId == EditorInfo.IME_ACTION_SEARCH
        || event == null
        || event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
              .....Do some stuff();
    }
}

這篇關(guān)于onEditorAction() 中的 null keyevent 和 actionid = 0 (Jelly Bean/Nexus 7)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

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 操作標(biāo)簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測(cè)向左或向右滑動(dòng)?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉(zhuǎn)對(duì)話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點(diǎn)擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設(shè)置為僅接受 Android 中的數(shù)值?)
主站蜘蛛池模板: 国产精品久久久久久久毛片 | 欧美精品一区二区三区在线播放 | 色资源站 | 欧美午夜影院 | 亚洲福利一区 | 国产传媒毛片精品视频第一次 | 99久久婷婷国产综合精品电影 | 狠狠艹| 亚洲一区视频在线 | 国产欧美在线视频 | 亚洲三区视频 | www性色| 91精品国产综合久久久久蜜臀 | 亚洲美女视频 | 午夜精品一区二区三区在线播放 | 三级免费 | 欧美一级片在线看 | 国产日韩欧美精品 | 欧美毛片免费观看 | 亚洲成人黄色 | 精品国产一区二区三区性色av | 亚洲欧美一区二区三区国产精品 | 日本成人在线网址 | av在线二区 | 精品久久久久一区二区国产 | 久久精品 | 亚洲综合色| 久久国色 | 免费一区二区三区在线视频 | 亚洲免费影院 | 久久久精 | 国产情侣久久 | 国产精品国产三级国产aⅴ中文 | 欧洲视频一区二区 | 亚洲成av人片在线观看 | 亚洲一区二区在线播放 | 国产激情一区二区三区 | www.一区二区三区.com | 日韩免费网站 | 综合在线视频 | 国产免费一区二区 |