반응형
Android는 온 스크린 키보드의 완료 키 누름을 감지합니다.
Done화상 키보드 의 키 를 눌렀을 때 감지 할 수 있습니까?
예, 가능합니다 :
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;
}
참고 URL : https://stackoverflow.com/questions/5077425/android-detect-done-key-press-for-onscreen-keyboard
반응형
'IT' 카테고리의 다른 글
Pandas Groupby : 결합 결합을 얻는 방법 (0) | 2020.08.07 |
---|---|
Entity Framework Core는 고유 한 제약 조건 코드 우선 추가 (0) | 2020.08.07 |
Retrofit 2로 모든 요청에 헤더 추가 (0) | 2020.08.07 |
C #에서 XmlNode에서 특성 값을 읽는 방법은 무엇입니까? (0) | 2020.08.07 |
Sublime Text 3 파일 사이드 바의 글꼴 크기를 변경하는 방법은 무엇입니까? (0) | 2020.08.06 |