簡體   English   中英

單擊EditText時如何禁用鍵盤?

[英]How can I disable the keyboard when clicking an EditText?

我用數字做了一個簡單的計算器。 我不希望鍵盤或您所謂的鍵盤在觸摸edittext時彈出。 我如何禁用它,以便可以安裝數字按鈕? 我的按鈕沒有問題,只有鍵盤沒有問題。

這可能有幫助https://stackoverflow.com/questions/1109022/how-to-close-hide-the-android-soft-keyboard

您還可以做的是檢測用戶何時選擇UI組件,例如:

txtEdit.setOnTouchListener(new View.OnTouchListener(){
    public boolean onTouch(View view, MotionEvent motionEvent) {                                                       
         // your code here....
         getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);                
         return false;
    }
});

取自(https://stackoverflow.com/questions/3389201/detect-touch-on-edittext-but-not-interrupt-it

您也可以只使用TextView並根據按下的按鈕編輯其中的文本。

如果我正確理解了您的要求,那么您想打開EditText所在的布局,並在其屬性下將其“輸入類型”更改為“數字”,或者只是使您的EditText在xml文件中看起來像這樣:

                <EditText
                android:id="@+id/YourEditText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:inputType="number" />

重要的一行是android:inputType="number"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM