level 8
真心求助,度娘已帮不了我。
点击EditText的时候如何屏蔽软键盘弹出,同时要显示光标。在小米2sc上可以实现,但是貌似在安卓4.4.2以上版本是无效的。大神们能给我提供一段代码吗?跪谢了。
2015年09月10日 08点09分
1
level 11
/*
* 禁止EditText弹出软件盘,光标依然正常显示。
*/
public void disableShowSoftInput(EditText editText) {
if (android.os.Build.VERSION.SDK_INT <= 10) {
editText.setInputType(InputType.TYPE_NULL);
} else {
Class<EditText> cls = EditText.class;
Method method = null;
try {
method = cls.getMethod("setShowSoftInputOnFocus", boolean.class);
method.setAccessible(true);
method.invoke(editText, false);
} catch (Exception e) {
// TODO: handle exception
}
}
}
2015年09月10日 09点09分
3
{ Class<EditText> cls = EditText.class; Method setSoftInputShownOnFocus; setSoftInputShownOnFocus = cls.getMethod("setSoftInputShownOn
2015年09月10日 09点09分
貌似4.4不支持
2015年09月10日 09点09分
level 8
{
Class<EditText> cls = EditText.class;
Method setSoftInputShownOnFocus;
setSoftInputShownOnFocus = cls.getMethod("setSoftInputShownOnFocus", boolean.class);
//4.0的是setShowSoftInputOnFocus,4.2的是setSoftInputShownOnFocus
setSoftInputShownOnFocus.setAccessible(true);
setSoftInputShownOnFocus.invoke(t, false);
}
2015年09月10日 09点09分
4