Clearing previously entered text in EditText field
Errr...
The only code I use to achieve 1) is:
// Clear text when clicked
host.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
host.setText("");
}
});
host
just being an EditText. Works just fine? I think you are making this more complicated than it is.
To clear When Clear Button is Clicked:
firstName = (EditText) findViewById(R.id.firstName);
clear = (Button) findViewById(R.id.clearsearchSubmit);
clear.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (v.getId() == R.id.clearsearchSubmit);
firstName.setText("");
}
});
It Worked For me. Hope It Helps.