답변:
예, 가능합니다 :
editText = (EditText) findViewById(R.id.edit_text);
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
// do your stuff here
}
return false;
}
});
다음 라이브러리를 가져와야합니다.
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;
편집기 정보는 Android 애플리케이션에서 모든 유형의 사용자 입력을 처리해야 할 때 가장 유용한 클래스입니다. 예를 들어 로그인 / 등록 / 검색 작업에서보다 정확한 키보드 입력을 위해 사용할 수 있습니다. 편집기 정보 클래스는 입력 방법이 편집 텍스트 내용과 직접 통신 할 텍스트 편집 개체에 대한 여러 속성을 설명합니다.
IME_ACTION_DONE으로 시도 할 수 있습니다 .
이 작업은 Done입력 할 항목 이없는 작업을 수행하고이 IME닫힙니다.
EditTextObj.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_DONE) {
/* Write your logic here that will be executed when user taps next button */
handled = true;
}
return handled;
}
});
버터 나이프를 사용하면
@OnEditorAction(R.id.signInPasswordText)
boolean onEditorAction(TextView v, int actionId, KeyEvent event){
if (actionId == EditorInfo.IME_ACTION_DONE || event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
/* Write your logic here that will be executed when user taps next button */
}
return false;
}
EditorInfo.IME_ACTION_SEARCH대신 렌즈 검색 버튼 을 사용해야 했습니다.