안드로이드 개발 질문/답변
(글 수 45,052)
보통 입력받은 데이터를 검색한다던지 이동할 때 키패드에서
버튼을 누르면 바로 실행되게 많이들 구현하는데요..
값을 입력하고 키패드의 "완료"키를 누르면 바로 실행되게 하고 싶은데여
onKeyDown이벤트에 보면 그 부분이 없더라구요.
혹시 방법이 있는지요 올려봅니다~
버튼을 누르면 바로 실행되게 많이들 구현하는데요..
값을 입력하고 키패드의 "완료"키를 누르면 바로 실행되게 하고 싶은데여
onKeyDown이벤트에 보면 그 부분이 없더라구요.
혹시 방법이 있는지요 올려봅니다~
2011.03.13 20:37:31
완료키대신 엔터키가 나오게 하고 엔터키에 대한 액션을 만들어놓으면 될것 같은데요...
완료키 대신 엔터키가 나오게 하는법은 모르겠습니다만, 되긴 할겁니다...
2011.03.13 20:43:03
softkeyboard 샘플에서
LatinKeyboard.java 의 아래 부분을 보세요~. 상황에 맞게 Send, Next, Go 등으로 바뀌게도 되고
액션도 취합니다.
/**
* This looks at the ime options given by the current editor, to set the
* appropriate label on the keyboard's enter key (if it has one).
*/
void setImeOptions(Resources res, int options) {
if (mEnterKey == null) {
return;
}
switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
case EditorInfo.IME_ACTION_GO:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_go_key);
break;
case EditorInfo.IME_ACTION_NEXT:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_next_key);
break;
case EditorInfo.IME_ACTION_SEARCH:
mEnterKey.icon = res.getDrawable(
R.drawable.sym_keyboard_search);
mEnterKey.label = null;
break;
case EditorInfo.IME_ACTION_SEND:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_send_key);
break;
default:
mEnterKey.icon = res.getDrawable(
R.drawable.sym_keyboard_return);
mEnterKey.label = null;
break;
}
}
LatinKeyboard.java 의 아래 부분을 보세요~. 상황에 맞게 Send, Next, Go 등으로 바뀌게도 되고
액션도 취합니다.
/**
* This looks at the ime options given by the current editor, to set the
* appropriate label on the keyboard's enter key (if it has one).
*/
void setImeOptions(Resources res, int options) {
if (mEnterKey == null) {
return;
}
switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
case EditorInfo.IME_ACTION_GO:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_go_key);
break;
case EditorInfo.IME_ACTION_NEXT:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_next_key);
break;
case EditorInfo.IME_ACTION_SEARCH:
mEnterKey.icon = res.getDrawable(
R.drawable.sym_keyboard_search);
mEnterKey.label = null;
break;
case EditorInfo.IME_ACTION_SEND:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_send_key);
break;
default:
mEnterKey.icon = res.getDrawable(
R.drawable.sym_keyboard_return);
mEnterKey.label = null;
break;
}
}



