For example: I enter 1 in edittext then again if i type 2 in same edittext then not want to remove manualy 1 but want to override it directly from 1 to 2.
For Example:
editTextOtpFirst.addTextChangedListener(this);
editTextOtpSecond.addTextChangedListener(this);
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (editTextOtpFirst.getText().length() ==1 && !checkEditTextEmpty(editTextOtpFirst)) {
editTextOtpSecond.requestFocus();
}
if (editTextOtpSecond.getText().length() ==1 && !checkEditTextEmpty(editTextOtpFirst) ) {
editTextOtpThird.requestFocus();
}
}
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (v.getId() == R.id.editTextOtpThird) {
if (event.getAction() == KeyEvent.ACTION_UP) {
if (keyCode == KeyEvent.KEYCODE_DEL) {
editTextOtpSecond.requestFocus();
return true;
}
}
}
if (v.getId() == R.id.editTextOtpFourth) {
if (event.getAction() == KeyEvent.ACTION_UP) {
if (keyCode == KeyEvent.KEYCODE_DEL) {
editTextOtpThird.requestFocus();
return true;
}
}
}
if (v.getId() == R.id.editTextOtpSecond) {
if (event.getAction() == KeyEvent.ACTION_UP) {
if (keyCode == KeyEvent.KEYCODE_DEL) {
editTextOtpFirst.requestFocus();
return true;
}
}
}
Now when i enter value "1" in edit text-1 then cursor move to the next edit text-2 but i want to change value of edit text-1 from "1" to "4" but need to remove manually "1" and then need to enter another value..but i do not want this...i want to direct override from "1" to "4" when i type another value in edit text.
I think your solution would be using the edit text hint instead of text. You can set the hint color to whatever color you want the text to be. Then you can use the
setHint
method.