我們希望在AutoCompleteTextView的活動啓動時顯示鍵盤默認值。 但AutocompletedTextview放置在其中一個片段類中。當fragement開始默認時,我們的鍵盤已顯示。如何在Android中的AutoCompleteTextView的Activity啓動時顯示鍵盤
我們試圖用三種情況:
案例1:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
案例2:
auto_phone.requestFocus();//auto_phone is AutoCompleteTextView
auto_phone.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_DOWN && (keyCode == KeyEvent.KEYCODE_ENTER))) {
return sendChatMessage();//method
}
return false;
}
案例3:
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(auto_phone, 0);
我們在清單文件中使用也爲作爲鍵盤Visibl的活動e
請指導我們。 高級謝謝!
嘗試使用'imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,InputMethodManager.HIDE_IMPLICIT_ONLY);'的情況下,3 –