umerk44
umerk44

Reputation: 2817

Keydown is not working

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;
        }

    });

Upvotes: 3

Views: 426

Answers (1)

Simon Dorociak
Simon Dorociak

Reputation: 33495

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:

Upvotes: 1

Related Questions