如何prevent键盘的EditText onTouch显示? [英] How to prevent keyboard to show in EditText onTouch?
本文介绍了如何prevent键盘的EditText onTouch显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要做的是这样的:我有一个EditText,当它在用户点击,用户可以通过移动插入符的位置,相同的EditText,但没有显示出键盘
What I want to do is this: I have an EditText and when the user click on it, the user can move the caret position, same as the EditText, but without showing the keyboard.
我试着setInputType(0);它完全地隐藏了键盘,但光标不会出现。
I've tried with setInputType(0); and it hides completly the keyboard but the cursor doesn't appears.
有没有办法做到这一点?
Is there any way to do this?
感谢的
推荐答案
下面的技巧为我工作。加字符和软键盘EDITTEXT都积极onTouch事件。于是呼触摸事件,然后手动隐藏键盘。
The following tricks works for me. Caret and soft keyboard both active onTouch event of editText. So Call touch event and then hide the keyboard manually.
myEditText.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
final boolean ret = dialerNumber.onTouchEvent(event);
final InputMethodManager imm = ((InputMethodManager) myContext
.getSystemService(Context.INPUT_METHOD_SERVICE));
try{
imm.hideSoftInputFromWindow(myEditText.getApplicationWindowToken(), 0);
}catch(Exception e){
e.printStackTrace();
}
return ret;
});
这篇关于如何prevent键盘的EditText onTouch显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文