0

I have multiple edit text fields. I want to move the cursor to the end when I tap on one of them. But the following code does not seem to work. It just places cursor where I tap.

    editText1.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if(editText1.hasFocus()){
                Toast.makeText(getContext(), "Got the focus", Toast.LENGTH_SHORT).show();
                editText1.setSelection(editText1.getText().length());

            }
        }
    });

0 Answers0