/code
Last active
February 10, 2017 02:18
Revisions
-
fyhack renamed this gist
Nov 6, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
fyhack created this gist
Nov 6, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ if (android.os.Build.VERSION.SDK_INT <= 10) { //2.3版本之前使用此方法 edit.setInputType(InputType.TYPE_NULL); } else { //2.3版本以后用反射方法设置setSoftInputShownOnFocus(4.0)的值解决 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); try { Class<EditText> cls = EditText.class; Method setSoftInputShownOnFocus; setSoftInputShownOnFocus = cls.getMethod("setSoftInputShownOnFocus", boolean.class); setSoftInputShownOnFocus.setAccessible(true); setSoftInputShownOnFocus.invoke(edit, false); } catch (Exception e) { e.printStackTrace(); } try { // 有部分SDK的方法名字为setShowSoftInputOnFocus(4.2) Class<EditText> cls = EditText.class; Method setShowSoftInputOnFocus; setShowSoftInputOnFocus = cls.getMethod("setShowSoftInputOnFocus", boolean.class); setShowSoftInputOnFocus.setAccessible(true); setShowSoftInputOnFocus.invoke(edit, false); } catch (Exception e) { e.printStackTrace(); } }