androidedittext鍵盤
Ⅰ 在android中點擊EditText的時候會彈出軟鍵盤,這時候如果想隱藏軟鍵盤或者填完內容後點其他的地方直接隱藏
1)在Manifest.xml文件中相應的activity下添加一下代碼:
android:windowSoftInputMode="stateHidden"
2)讓EditText失去焦點,使用EditText的clearFocus方法
例如:EditText edit=(EditText)findViewById(R.id.edit);
edit.clearFocus();
3)強制隱藏Android輸入法窗口
例如:EditText edit=(EditText)findViewById(R.id.edit);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edit.getWindowToken(),0);
4).EditText始終不彈出軟體鍵盤
例:EditText edit=(EditText)findViewById(R.id.edit);
edit.setInputType(InputType.TYPE_NULL);
Ⅱ android editText 如何自動顯示軟鍵盤
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
//隱藏軟鍵盤
// imm.hideSoftInputFromWindow(editView.getWindowToken(), 0);
//顯示軟鍵盤
// imm.showSoftInputFromInputMethod(editView.getWindowToken(), 0);
//切換軟鍵盤的顯示與隱藏
imm.toggleSoftInputFromWindow(editView.getWindowToken(), 0, InputMethodManager.HIDE_NOT_ALWAYS);
Ⅲ android 有一行edittext 輸入數字,如何設置數字鍵盤輸完一個按enter鍵接著
EditTextet=(EditText)findViewById(R.id.editNum);et.setInputType(InputType.TYPE_CLASS_NUMBER);給你的EditText設置輸入類型TYPE_CLASS_NUMBER,這樣你在點擊EditText的時候,默認彈出的鍵盤模式就是數字鍵盤。
Ⅳ Android ListView下方放一個EditText,軟鍵盤彈出問題。
找到問題原因了,是因為我的ListView設置了android:transcriptMode="alwaysScroll"屬性,去掉就好了。
android:windowSoftInputMode設置為"stateHidden|adjustUnspecified"其實在我這里adjustUnspecified應該等價於ReSize吧
沒做實驗驗證。恩,總之,謝謝大家了。
Ⅳ Android的EditText在怎樣獲取焦點並彈出軟鍵盤
//讓編輯框彈出來,並顯示對誰進行評論
commentEditText.setFocusable(true);
commentEditText.setFocusableInTouchMode(true);
commentEditText.requestFocus();
//打開軟鍵盤
InputMethodManagerimm=(InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);
- //讓編輯框彈出來,並顯示對誰進行評論
commentEditText.setFocusable(true);
commentEditText.setFocusableInTouchMode(true);
commentEditText.requestFocus();
//打開軟鍵盤
InputMethodManagerimm=(InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);上面的代碼,能夠讓EditText獲取焦點,並彈出軟鍵盤,供輸入文本內容。特別適用於評論列表之類的場景。
Ⅵ android開發EditText輸入時彈出數字輸入鍵盤
一共有兩種方法:
1.可以直接在布局文件中設置輸入文本類型為數字
<EditText
android:id="@+id/editview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:hint="請輸入數字"/>
2.代碼設置:
( EditText) et = (EditText) findViewById(R.id.editview);
ed.setInputType(InputType.TYPE_CLASS_NUMBER);