I have two EditText
fields in my activity and a done button
. I want both the EditText
fields to loose focus (that is the cursor should not not be displayed on either of them) when the user presses the button. I am using the following code:
final Button saveButton = (Button) findViewById(R.id.saveButton);
saveButton.setOnClickListener(saveButtonListener);
private OnClickListener saveButtonListener = new OnClickListener() {
@Override
public void onClick(View v) {
Text1.clearFocus();
Text2.clearFocus();
}
}
However, when I press the done button, the cursor comes up on Text1
even if I haven't clicked on any EditText
yet. How can I make the EditText fields loose focus on the click of the button