하나의 문제점이있는 사용자 정의 키보드에서 작업하고 있습니다. On key 청취자 현재 커서 위치를 다음 줄으로 설정해야합니다. 나는 다음 라인에없는 텍스트의 마지막에 현재 커서의 위치를 설정Edittext는 커서를 다음 줄로 설정합니다.
editText.setSelection(editText.getText().length());
를 사용하여 시도 했다.
하나의 문제점이있는 사용자 정의 키보드에서 작업하고 있습니다. On key 청취자 현재 커서 위치를 다음 줄으로 설정해야합니다. 나는 다음 라인에없는 텍스트의 마지막에 현재 커서의 위치를 설정Edittext는 커서를 다음 줄로 설정합니다.
editText.setSelection(editText.getText().length());
를 사용하여 시도 했다.
사용
<EditText
android:id="@+id/fnameUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:background="@drawable/text_bar"
android:hint="First Name"
**android:text="@string/newline"**
android:textColor="#ffffff"
android:padding="5dp" />
곳
<string name="newline">\n</string>
새 줄 삽입이 Enter 키으로되어 있는지 여부가 나에게 분명하지 않습니다. 메모장.
int position = editText.getSelectionStart();
editText.getText().insert(position, "\n");
editText.setSelection(position + 1);
를 그렇지 않으면 그냥 텍스트 주위에 이동하려는 경우 당신이 할 수있는, : 당신이 삽입하기 전에 커서의 현재 위치를 기억 할 수 있습니다 이외의 경우의 uval의 대답에 는 잘 보인다 화살표 키 메모장에, 당신은 아마 당신의보기의 주어진 너비와 텍스트의 크기에 따라 라인 당 문자의 수를 계산하고 다음 라인의 수와 위치를 가져야합니다.
다음 줄 또는 다음 편집기로? – auval
@uval 다음 줄 ... – Aniket