일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 작성중
- Qmail
- Algorithm
- eclipse35
- 안드로이드
- IPTV
- 주식
- Audacity
- Android
- UX
- IT 키워드
- java
- 도서
- Linux
- 알고리즘
- unix
- uml example
- LDAP
- adb
- 기술사
- KOSPI
- 코스피
- conemu
- Eclipse
- 공매도
- 우분투
- 보안
- 태터수정
- ubuntu
Archives
- Today
- Total
Do diffence
IME 관련 정리 본문
10-09-17: 안드로이드 입력박스에서 소프트키보드 처리에 대한 것을 정리하고 있다.
Emulator 와 키보드
보통 기본으로 생성되는 에뮬레이터는 키보드가 달려있는 것을 가정하기 때문에 소프트키보드가 가로모드에서 표시되지 않는다. AVD 생성시 속성으로 Keyboard Support를 NO로 하고 사용한다.
EditText ime 관련 속성
android:imeOptions="actionDone"android:imeActionLabel="검색"android:inputType="textShortMessage"
키보드 타입 설정
EditText에서 다음과 같이 설정시 한글키보드가 로딩 됩니다.
android:inputType="textShortMessage"android:inputType="textLongMessage"android:inputType="textWebEditText"
키보드 언어 지정
입력 모드를 아래와 같이 영어나 숫자로 변경이 가능하다. 지역설정이 한국으로 되어 있으면 default 값은 한글 입니다. SDK 2.2.이후
yourTextView.setPrivateImeOptions("defaultInputmode=numeric");
or
"defaultInputmode=korea"
"defaultInputmode=english"
소프트키 입력시 미리보기 제거
onCreateInputView()mInputView.setPreviewEnabled(false);
키보드 서비스
InputMethodManager inputManager = (InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE);inputManager.hideSoftInputFromWindow(editText.getWindowToken(), 0);
orinputManager.showSoftInput( getCurrentFocus(), 0);
소프트키보드 액션 처리
EditText.setOnEditorActionListener() 사용
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
Log.d(TAG, "EditorInfo action: " + actionId);
if ((actionId == EditorInfo.IME_ACTION_DONE) ||
(event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
mSearchWord = v.getText().toString();
if( !"".equals(mSearchWord) ) {
mSearchHandler.sendEmptyMessage(1);
}}return false;}
소프트키보드 액션/키 제어
private Handler softinputHandler = new Handler(){
public void handleMessage(Message msg){
}
};
// ime의 결과를 제어할 때.// mInputManager.showSoftInput( mSearchEdit, InputMethodManager.SHOW_IMPLICIT, new SoftInputResultReceiver());
public class SoftInputResultReceiver extends ResultReceiver {
public SoftInputResultReceiver() {
super( softinputHandler);
}
protected void onReceiveResult(int resultCode, Bundle resultData) {
super.onReceiveResult(resultCode, resultData);
switch (resultCode) {
case InputMethodManager.RESULT_HIDDEN:
hiddenFocusListener.onFocusChange(mHiddenforcus, true);
break;
case InputMethodManager.RESULT_SHOWN:
break;
case InputMethodManager.RESULT_UNCHANGED_SHOWN:
break;
case InputMethodManager.RESULT_UNCHANGED_HIDDEN:
break;
default:
break;
}
}
}