不多说了,直接上代码
package
/** * Author: blueZhang * Date: 2015/12/15 0015 * 163Email :[email protected] * QEmail:[email protected] * QQ:2029379603 */
import android.content.Context;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
/** * 打开或者是关闭软键盘的工具类,用来开启或者是关闭软键盘 */
public final class SoftKeyBoardUtil {
private SoftKeyBoardUtil(){}
/** * 开启软键盘 * @param mediEditText 进行输入的EditText * @param mContext 上下文对象 */
public static void openKeyBoard (EditText mediEditText,Context mContext){
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mediEditText,InputMethodManager.RESULT_UNCHANGED_SHOWN);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,InputMethodManager.HIDE_IMPLICIT_ONLY);
}
/** * 关闭软键盘 * @param mEditText 需要进行输入的软键盘 * @param mContext 上下文对象 */
public static void closeKeyBoard(EditText mEditText,Context mContext){
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mEditText.getWindowToken(),0);
}
}