OnClickListener侦听仅在第二时间 [英] OnClickListener listens only on the second time
本文介绍了OnClickListener侦听仅在第二时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个EDITTEXT,并增加了一个onClickListener到它。在点击的方法,我只是清除文本。当我点击EDITTEXT首次键盘弹出。但它不进入onClick的方法。当我点击它,它被调用,并清除文本的第二次。
I have an editText and have added an onClickListener to it. In the click method I am just clearing the text. When I click the editText first time the keypad pops up. But it is not going into the onClick method. The second time when I click it it is called and clears the text.
qtyEditTxt=(EditText)findViewById(R.id.qtyet);
qtyEditTxt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
qtyEditTxt.setText("");
}
});
我看到一个答案说明,以使Android一个问题:focusableInTouchMode为false。但后来我将无法输入文本。请帮我这个
I saw a question with an answer stating to make android:focusableInTouchMode to false. But then I will not be able to enter the text. Kindly help me with this
推荐答案
如何聚焦?
final EditText qtyEditTxt= (EditText) findViewById(R.id.qtyet);
qtyEditTxt.setOnFocusChangeListener(new OnFocusChangeListener()
{
@Override
public void onFocusChange(View v, boolean isFocus)
{
if (isFocus)
{
qtyEditTxt.setText("");
}
}
});
编辑:
默认的文字?你去那里:)
Default text? There you go :)
android:hint="Enter Quantity"
这篇关于OnClickListener侦听仅在第二时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文