1. 程式人生 > >android中EditText有游標不彈出軟鍵盤處理(轉)

android中EditText有游標不彈出軟鍵盤處理(轉)

if (android.os.Build.VERSION.SDK_INT <= 10) {
et_input_batch_num_in.setInputType(InputType.TYPE_NULL);
} else {
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
try {
Class<EditText> cls = EditText.class;
Method setSoftInputShownOnFocus;
setSoftInputShownOnFocus = cls.getMethod("setShowSoftInputOnFocus", boolean.class);
setSoftInputShownOnFocus.setAccessible(true);
setSoftInputShownOnFocus.invoke(edit, false);
} catch (Exception e) {
e.printStackTrace();
}
  }