android关闭和打开软键盘和判断设备是否为大尺寸屏幕
public class CloseSofterInput {
public void hideSoftInput(Activity activity) {
// 关闭软键盘
InputMethodManager im = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (activity.getCurrentFocus() != null) {
im.hideSoftInputFromWindow(activity.getCurrentFocus()
.getApplicationWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
}
public void showSoftInput(final Activity activity) {
(new Handler()).postDelayed(new Runnable() {
public void run() {
InputMethodManager inManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
inManager.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
}
}, 1000);
}
}
public static boolean isScreenSizeLarge(Context context) { //判断设备是否为大尺寸屏幕
return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}
```
你尚未登录,无法进行回复。