android - EditText is not detecting keys -


in fragment class i've put code in oncreateview monitor if user presses enter, not working , not capturing other keyboard press. n.b.: i'm testing on virtual emulator.

@override     public view oncreateview(layoutinflater inflater, viewgroup container,bundle savedinstancestate)     {         view rootview = inflater.inflate(r.layout.fragment_sub, container, false);           edittext addproduct = (edittext)rootview.findviewbyid(r.id.edittext1);         addproduct.setonkeylistener(new onkeylistener() {              @override             public boolean onkey(view v, int keycode, keyevent event) {                 log.i("any button","button");                 // if keydown , "enter" pressed                 if ((event.getaction() == keyevent.action_down) && (keycode == keyevent.keycode_enter)) {                     ((edittext)v).settext("");                     log.i("here","im here");                     return true;                  } else if ((event.getaction() == keyevent.action_down) && (keycode == keyevent.keycode_9)) {                      ((edittext)v).settext("");                     log.i("or here","9");                     return true;                 }                 //do stuff here against pressing shift key                  return false;             }         });         return rootview;         } 

the onkey function detects hardware keys, not soft keys. onscreen keyboard, need implement textwatcher.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -