您的位置:首页 > 其它

判断软键盘,显示或隐藏

2013-06-27 16:25 232 查看
1.类imeutil.java

public class ImeUtil {

    public
static void hideIme(Activity context){

       
if(context==null)

           
return;

       
final View v = context.getWindow().peekDecorView();

       
if (v != null && v.getWindowToken() != null) {

           
InputMethodManager imm = (InputMethodManager)
context.getSystemService(context.INPUT_METHOD_SERVICE);

           
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

       
}

    }

    public
static boolean isImeShow(Context context){

       
InputMethodManager imm = (InputMethodManager)
context.getSystemService(context.INPUT_METHOD_SERVICE);

       
return imm.isActive();

    }

}

 

2.调用判断方法

if(ImeUtil.isImeShow(view.getContext()))

ImeUtil.hideIme((Activity)view.getContext());

else

view.ShowInputEdit();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: