android - Error to updating EditText -
on devices, code, edittext to_quantity not updated in real time during insertion of value converted in edittext from_quantity. can problem?
edit text from_quantity:
from_quantity.setonkeylistener(new onkeylistener(){ public boolean onkey(view v, int keycode, keyevent event){ try{ if(!(double.isnan(double.valueof(from_quantity.gettext().tostring())))){ convert(from_quantity.gettext().tostring(), "to"); } }catch(numberformatexception e){ log.d("error", e.tostring()); } return false; } }); from_quantity.setontouchlistener(new ontouchlistener(){ public boolean ontouch(view v, motionevent event) { //clear quantities from_quantity.settext(""); to_quantity.settext(""); return false; } }); edit text to_quantity:
to_quantity.setonkeylistener(new onkeylistener() { public boolean onkey(view v, int keycode, keyevent event) { try{ if(!(double.isnan(double.valueof(to_quantity.gettext().tostring())))) { convert(to_quantity.gettext().tostring(), "from"); } } catch(numberformatexception e) { log.d("error", e.tostring()); } return false; } }); to_quantity.setontouchlistener(new ontouchlistener(){ public boolean ontouch(view v, motionevent event) { //clear quantities from_quantity.settext(""); to_quantity.settext(""); return false; } });
if use soft keyboard of device, onkeylistener not called. should use textwatcher.
Comments
Post a Comment