每当我触摸edittext时,光标都应该在末尾。

 editTextView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {

                    editTextView.onTouchEvent(event);

                    if(!textFocus) {
                        editTextView.setSelection(editTextView.getText().length());
                        textFocus = true;
                    }

                    return true;
                }
            });

            editTextView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                @Override
                public void onFocusChange(View v, boolean hasFocus) {
                    textFocus = false;
                }
            });

最佳答案

这对我有帮助。总是当我触摸edittext时,光标会在末尾

editTextView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    editTextView.onTouchEvent(event);
                    editTextView.setSelection(editTextView.getText().length());
                    return true;
                }
            });

10-04 10:59