import android.content.Context;
import android.os.IBinder;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
public class InputMethodUtils {
private InputMethodUtils() {
throw new UnsupportedOperationException("This class cannot be instantiated, and its methods must be called directly.");
}
private static InputMethodManager inputMethodManager = null;
public static void init(Context context) {
inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
}
public static boolean isActive() {
return inputMethodManager.isActive();
}
public static void toggleSoftInput() {
inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
public static void showSoftInput(View view) {
inputMethodManager.showSoftInput(view, InputMethodManager.RESULT_SHOWN);
}
public static void hideSoftInputFromWindow(IBinder token) {
inputMethodManager.hideSoftInputFromWindow(token, 0);
}
}
InputMethodUtils
最新推荐文章于 2022-01-26 10:45:14 发布