放置在滚动视图时,如何从解雇EDITTEXT键盘 [英] how to dismiss keyboard from editText when placed in scroll view
本文介绍了放置在滚动视图时,如何从解雇EDITTEXT键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好我已创建一个登录表单,在那里我有这是摆在滚动view.what我想编辑的文字和buttos是取消键盘当我触摸编辑文本以外的科幻已经实现了滚动型onTouch监听器关闭键盘但我想is.both滚动和keyboard.is解雇有可能低于?什么是code。
滚动型SV =(滚动型)findViewById(R.id.scroll);
sv.setOnTouchListener(新OnTouchListener(){ @覆盖
公共布尔onTouch(视图V,MotionEvent事件){
// TODO自动生成方法存根
InputMethodManager IMM =(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus()getWindowToken(),0);
返回true;
}
});
解决方案
您是通过返回消耗滚动型
的触摸事件
返回true;
刚刚返回假
这将使触摸事件父。
Hi guys i have created a login form where i have edit text and buttos which is placed in a scroll view.what i want is to dismiss the keyboard when i touch outside the edit text f.i have implemented scrollview onTouch Listener to dismiss keyboard but what i want is.both scroll and dismissal of the keyboard.is it possible?below is the code.
ScrollView sv=(ScrollView) findViewById(R.id.scroll);
sv.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
InputMethodManager imm = (InputMethodManager) getSystemService( INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
return true;
}
});
解决方案
you are consuming the touch event of ScrollView
by returning
return true;
just return false
It will give the touch event to the parent.
这篇关于放置在滚动视图时,如何从解雇EDITTEXT键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文