我在DialogFragment
对话框打开时onCreateDialog
使用来显示键盘。InputMethodManager
但是,由于某种原因它不起作用。有谁知道为什么?
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder b = new Builder(getActivity());
b.setMessage("Enter a 5 digit zipcode");
final EditText et = new EditText(getActivity());
et.setInputType(InputType.TYPE_CLASS_NUMBER);
et.requestFocus();
et.setHint("Zipcode");
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(INPUT_METHOD_SERVICE);
imm.showSoftInput(et, InputMethodManager.SHOW_FORCED);
b.setView(et);
return b.create();
}