Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keydown is not working

Tags:

android

hi i wanted to populate one text box from the input of other text box on every key press but this is not happening. 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;
        }

    });
like image 710
umerk44 Avatar asked Jan 17 '26 17:01

umerk44


1 Answers

hi i wanted to populate one text box from the input of other text box on every key press but this is not happening. the code is like this

I suggest to you use TextChangedListener with TextWatcher instead of KeyListener. I think it is more suitable to use to reach your goal and work with it is more comfortable.

Here is example:

like image 64
Simon Dorociak Avatar answered Jan 20 '26 10:01

Simon Dorociak