Android(安卓)软键盘相关辅助类KeyBoardUtils
16lz
2021-12-04
package utils;import android.content.Context;import android.view.inputmethod.InputMethodManager;import android.widget.EditText;/** * * Created by GGJ on 2018/5/2. * */public class KeyBoardUtils { /** * 打卡软键盘 * * @param mEditText * 输入框 * @param mContext * 上下文 */ public static void openKeybord(EditText mEditText, Context mContext) { InputMethodManager imm = (InputMethodManager) mContext .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(mEditText, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); } /** * 关闭软键盘 * * @param mEditText * 输入框 * @param mContext * 上下文 */ public static void closeKeybord(EditText mEditText, Context mContext) { InputMethodManager imm = (InputMethodManager) mContext .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0); }}
更多相关文章
- android强制弹出键盘
- android 模拟按键
- android监听键盘弹出or隐藏方法
- android使用同一个RecyclerView实现两种不同Item布局
- android显示隐藏软键盘
- android隐藏以及显示软键盘
- android软键盘问题
- Android之常用功能代码
- Android(安卓)响应键盘移动图标