当我的片段开始时,我希望我的EditText获得焦点并让用户可以在其中直接开始输入。我使用requestFocus()方法可以将其设为焦点,但是我无法让键盘弹出。
我已经尝试了以下方法:
我已经尝试了以下方法:
edit = (EditText) view.findViewById(R.id.search);
edit.requestFocus();
InputMethodManager imgr = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imgr.showSoftInput(edit, 0);
和
edit = (EditText) view.findViewById(R.id.search);
InputMethodManager imgr = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imgr.showSoftInput(edit, 0);
edit.requestFocus();
如何使EditText出现键盘?