将onClickListener设置为editText [英] Setting onClickListener to editText
本文介绍了将onClickListener设置为editText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我想在点击侦听器上添加editText,以便当用户使用以下代码点击edittext时可以禁用软键盘,该怎么做?
Hi im trying to add on click listener to editText so i can disable the softkeyboard when user clicks on edittext using this code below, how to do that?
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
推荐答案
首先,它必须具有可聚焦性...
First it needs to be focusable...
<EditText
...
android:inputType="none"
android:focusable="false"
... />
您必须在代码中实现它,而不仅仅是添加它以获得点击侦听器...
You have to implement it in your code and than just add this to get an click listener...
myEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// hide the keyboard
// show own keyboard or buttons
}
});
这篇关于将onClickListener设置为editText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文