android - How to override text of edit text when maxLength of edittext is 1 -
for example: enter 1 in edittext again if type 2 in same edittext not want remove manualy 1 want override directly 1 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 enter value "1" in edit text-1 cursor move next edit text-2 want change value of edit text-1 "1" "4" need remove manually "1" , need enter value..but not want this...i want direct override "1" "4" when type value in edit text.
i think solution using edit text hint instead of text. can set hint color whatever color want text be. can use sethint
method.
Comments
Post a Comment