Hello,
I have been searching the net for an answer to this question for awhile now and am hoping for some guidance here.
Overview: I have 3 EditText fields that a user can enter integer values into. When the user selects one of the fields, I want the other two go back to their default state. In other words, go back to showing just the hint it is pre-populated with. I tried implementing a TextView watcher and setting the other fields to blank in "afterChanged" but I kept getting a stack overflow.
I then tried an onClickListener and that sortof worked. I have to click on the edittext field twice before the other two go blank. Its almost like the initial click doesn't invoke onClick(). Here is the code:
first_et = (EditText) findViewById(R.id.first_et);
second_et = (EditText) findViewById(R.id.second_et);
third_et = (EditText) findViewById(R.id.third_et);
private void setup_listeners() {
first_et.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
second_et.setText("");
third_et.setText("");
}
});
second_et.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
first_et.setText("");
third_et.setText("");
}
});
third_et.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
first_et.setText("");
second_et.setText("");
}
});
}
Any help would be appreciated.
Jake
I have been searching the net for an answer to this question for awhile now and am hoping for some guidance here.
Overview: I have 3 EditText fields that a user can enter integer values into. When the user selects one of the fields, I want the other two go back to their default state. In other words, go back to showing just the hint it is pre-populated with. I tried implementing a TextView watcher and setting the other fields to blank in "afterChanged" but I kept getting a stack overflow.
I then tried an onClickListener and that sortof worked. I have to click on the edittext field twice before the other two go blank. Its almost like the initial click doesn't invoke onClick(). Here is the code:
first_et = (EditText) findViewById(R.id.first_et);
second_et = (EditText) findViewById(R.id.second_et);
third_et = (EditText) findViewById(R.id.third_et);
private void setup_listeners() {
first_et.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
second_et.setText("");
third_et.setText("");
}
});
second_et.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
first_et.setText("");
third_et.setText("");
}
});
third_et.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
first_et.setText("");
second_et.setText("");
}
});
}
Any help would be appreciated.
Jake