java - Override the Numpad_Dot -


i have 4 edit texts; oct1, oct2, oct3, oct4. these edit texts type numberdecimal. have initial focus on oct1. need when user presses . (numpad dot) not enter . oct, clear focus , focus on next edit text.

this should easy, surprisingly frustrating me. have tried.

overriding onkeydown. won't produce logs.

    @override     public boolean onkeydown(int keycode, keyevent event) {        if(keycode == keyevent.keycode_numpad_dot){           oct3.clearfocus();           oct4.requestfocus();           return true;        }        log.d("keycode", string.valueof(keycode));        log.d("event", string.valueof(event));        return false; } 

then this. have many different variants of this. have been able switch focus this, not delete ..

    oct3.addtextchangedlistener(new textwatcher() {         @override         public void beforetextchanged(charsequence s, int start, int count, int after) {             //do nothing         }          @override         public void ontextchanged(charsequence s, int start, int before, int count) {             if(count > 0){                 if(s.charat(s.length()-1) == ".".charat(0)){                      log.d("sequence", "noticed \".\"");                     isperiod = true;                 } else {                     log.d("sequence", "noticed \""+s+"\"");                 }             }          }          @override         public void aftertextchanged(editable s) {             if(isperiod){                 s.delete(s.length() -1, s.length() -1);                 oct3.clearfocus();                 isperiod = false;                 oct4.requestfocus();             }         }     }); 

try setting in ontextchanged:

  listener = (new textwatcher() {         @override         public void beforetextchanged(charsequence s, int start, int count, int after) {          }          @override         public void ontextchanged(charsequence s, int start, int before, int count) {             if(count > 0){                 if(s.charat(s.length()-1) == '.'){                     log.d("sequence", "noticed \".\"");                     charsequence text = s.subsequence(0, s.length()-1);                     log.d("view clicked:", string.valueof(getcurrentfocus()));                     settextandadvance(getcurrentfocus(), text);                 } else {                     log.d("sequence", "noticed \""+s+"\"");                 }             }         }          @override         public void aftertextchanged(editable s) {          }     }); 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -