package com.sun.bingo.util;
import android.app.Activity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
public class KeyBoardUtil {
/**
* 收起软键盘
*/
public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0);
}
}
/**
* 弹出软键盘
*/
public static void showKeyboard(final View view) {
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.requestFocus();
view.postDelayed(new Runnable() {
@Override
public void run() {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.showSoftInput(view, InputMethodManager.RESULT_UNCHANGED_SHOWN);
}
}, 400);
}
}