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

Android在不丟失光標(biāo)的情況下從EditText隱藏軟鍵盤

Android Hide Soft Keyboard from EditText while not losing cursor(Android在不丟失光標(biāo)的情況下從EditText隱藏軟鍵盤)
本文介紹了Android在不丟失光標(biāo)的情況下從EditText隱藏軟鍵盤的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我已經(jīng)完成了 這個(gè) 這讓我走到了一半,但并不完全.我有一個(gè)撥號(hào)器 Fragment,它有所有常用的 Button 來輸入數(shù)字,包括退格,所以我不需要軟鍵盤.我還想讓用戶能夠粘貼文本(長(zhǎng)按...默認(rèn)情況下可以正常工作),以及編輯輸入的內(nèi)容,所以我需要光標(biāo).

I've come about as far as this which gets me halfway there, but not quite. I have a dialer Fragment that has all the usual Buttons to enter a number including backspace, so I don't need the soft keyboard. I'd also like to give the user the ability to paste text (long click... works fine per default), as well as to edit what has been entered so I need the cursor.

如果用戶在 EditText 內(nèi)單擊,我發(fā)現(xiàn)確保不會(huì)彈出軟鍵盤的最簡(jiǎn)單方法是將 inputType 設(shè)置為 null - 但是也殺死光標(biāo).

The easiest way I found to make sure the soft keyboard doesn't pop up if the user clicks inside the EditText is to set the inputType to null - but that kills the cursor as well.

那么,我該如何聲明我的 EditText 以及我應(yīng)該啟動(dòng)什么樣的命令才能讓我的 EditText 字段永遠(yuǎn)不會(huì)顯示軟鍵盤,無論用戶嘗試什么,但仍保留粘貼功能和光標(biāo)?

So, how do I declare my EditText and what kind of commands should I launch to have my EditText field never ever show the soft keyboard no matter what the user attempts, but still retain paste functionality and the cursor?

我也在清單中嘗試了 android:windowSoftInputMode="stateAlwaysHidden",但無濟(jì)于事.

I've also tried android:windowSoftInputMode="stateAlwaysHidden" in my manifest, but to no avail.

推薦答案

這對(duì)我有用:

        // Update the EditText so it won't popup Android's own keyboard, since I have my own.
    EditText editText = (EditText)findViewById(R.id.edit_mine);
    editText.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            v.onTouchEvent(event);
            InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            if (imm != null) {
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
            }                
            return true;
        }
    });

這篇關(guān)于Android在不丟失光標(biāo)的情況下從EditText隱藏軟鍵盤的文章就介紹到這了,希望我們推薦的答案對(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ù)值?)
主站蜘蛛池模板: 久久91精品国产一区二区三区 | 日韩欧美在线观看 | 亚洲精品视频一区二区三区 | 久久久久国产一区二区三区 | 亚洲a人| 九九亚洲 | 一区二区精品 | 国产精品视频在线观看 | 国产yw851.c免费观看网站 | 国产一级视频在线播放 | 久久9999久久 | 巨大荫蒂视频欧美另类大 | 亚洲成人免费av | 久久免费视频在线 | 亚洲免费观看视频网站 | 欧美黄色一区 | 免费午夜视频在线观看 | 91性高湖久久久久久久久_久久99 | 中文福利视频 | 华丽的挑战在线观看 | 国产精品亚洲视频 | 日韩一区二区三区在线视频 | 成人夜晚看av | 日韩毛片 | 久草新在线 | 欧美日本韩国一区二区 | 中文日韩在线 | 美日韩精品 | 免费av在线网站 | 蜜桃官网| 99久久精品国产毛片 | 一区二区三区精品在线 | 欧美一区二区三区一在线观看 | 国产精品美女在线观看 | 成人av免费播放 | 三级黄色网址 | 91精品国产综合久久福利软件 | 成人亚洲片 | a视频在线 | 国产一区免费视频 | 伊人电影院av|