Keydown doesn't work
Hi I wanted to populate one textbox from the input of another textbox on every key press, but it doesn't. the code is like this
leftside.setOnKeyListener(new OnKeyListener()
{
@Override
public boolean onKey(View arg0, int arg1, KeyEvent arg2)
{
if(arg2.getAction() == KeyEvent.ACTION_DOWN)
{
Log.v("keyevent", "down");
float value = Float.parseFloat(leftside.getText().toString());
rightside.setText(String.valueOf(SelectConverter(Float.parseFloat(leftside.getText().toString()))));
}
// TODO Auto-generated method stub
return false;
}
});
+3
source to share
1 answer
Hi I wanted to populate one textbox in another textbox tab on every key press, but it doesn't. the code is like this
I suggest you use TextChangedListener
with TextWatcher
instead KeyListener
. I think that it is more suitable for achieving your goal, and it is more convenient to work with it.
Here's an example:
+1
source to share