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("");
}
});
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
How about focus?
final EditText qtyEditTxt= (EditText) findViewById(R.id.qtyet);
qtyEditTxt.setOnFocusChangeListener(new OnFocusChangeListener()
{
@Override
public void onFocusChange(View v, boolean isFocus)
{
if (isFocus)
{
qtyEditTxt.setText("");
}
}
});
Edited:
Default text? There you go :)
android:hint="Enter Quantity"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With