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

如何處理 ImeOptions 的完成按鈕點(diǎn)擊?

How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點(diǎn)擊?)
本文介紹了如何處理 ImeOptions 的完成按鈕點(diǎn)擊?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有一個(gè) EditText 我正在設(shè)置以下屬性,以便當(dāng)用戶單擊 EditText 時(shí)我可以在鍵盤上顯示完成按鈕.

I am having an EditText where I am setting the following property so that I can display the done button on the keyboard when user click on the EditText.

editText.setImeOptions(EditorInfo.IME_ACTION_DONE);

當(dāng)用戶單擊屏幕鍵盤上的完成按鈕(完成輸入)時(shí),我想更改 RadioButton 狀態(tài).

When user clicks the done button on the screen keyboard (finished typing) I want to change a RadioButton state.

如何在屏幕鍵盤點(diǎn)擊完成按鈕時(shí)跟蹤它?

How can I track done button when it is hit from screen keyboard?

推薦答案

我最終得到了 Roberts 和 chirags 的組合答案:

I ended up with a combination of Roberts and chirags answers:

((EditText)findViewById(R.id.search_field)).setOnEditorActionListener(
        new EditText.OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        // Identifier of the action. This will be either the identifier you supplied,
        // or EditorInfo.IME_NULL if being called due to the enter key being pressed.
        if (actionId == EditorInfo.IME_ACTION_SEARCH
                || actionId == EditorInfo.IME_ACTION_DONE
                || event.getAction() == KeyEvent.ACTION_DOWN
                && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
            onSearchAction(v);
            return true;
        }
        // Return true if you have consumed the action, else false.
        return false;
    }
});

更新:上面的代碼有時(shí)會(huì)激活回調(diào)兩次.相反,我選擇了從 Google 聊天客戶端獲得的以下代碼:

Update: The above code would some times activate the callback twice. Instead I've opted for the following code, which I got from the Google chat clients:

public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    // If triggered by an enter key, this is the event; otherwise, this is null.
    if (event != null) {
        // if shift key is down, then we want to insert the '
' char in the TextView;
        // otherwise, the default action is to send the message.
        if (!event.isShiftPressed()) {
            if (isPreparedForSending()) {
                confirmSendMessageIfNeeded();
            }
            return true;
        }
        return false;
    }

    if (isPreparedForSending()) {
        confirmSendMessageIfNeeded();
    }
    return true;
}

這篇關(guān)于如何處理 ImeOptions 的完成按鈕點(diǎn)擊?的文章就介紹到這了,希望我們推薦的答案對(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 you set EditText to only accept numeric values in Android?(您如何將 EditText 設(shè)置為僅接受 Android 中的數(shù)值?)
Contact Bubble EditText(聯(lián)系氣泡編輯文本)
主站蜘蛛池模板: 亚洲二区在线观看 | 狠狠躁夜夜躁人爽 | 国产毛片毛片毛片 | 久久国产免费 | 久久精品欧美一区二区三区不卡 | 涩涩的动漫 | 午夜激情福利 | 91久久| 国产一区二区在线看 | 免费观看黄色大片 | 亚洲毛片av | 日韩中文字幕在线观看 | 最近中文字幕在线 | 久久成人综合 | 国产欧美日韩综合 | 91国内精品| 不卡免费视频 | 日韩视频在线观看 | 亚洲在线视频观看 | 国产主播一区二区 | 五月天网址 | 欧美一区视频 | 三级黄色网 | 久久国产欧美 | 亚洲精品一二三四 | 五月播播 | 国产成人精品三级麻豆 | 神马香蕉久久 | 91黄色免费视频 | av在线播放免费 | 一区二区欧美日韩 | 欧美久久一区二区 | 国精产品99永久一区一区 | 久久精品一区二区国产 | 精品99视频 | 日韩精品在线一区 | 精品视频国产 | 亚洲精品乱码久久久久 | 中文字幕不卡 | 激情久久久 | 久久精品国产一区 |