2012년 8월 21일 화요일

안드로이드에서 키보드를 제어






fwefwewef
안드로이드에서 키보드를 제어할 필요가 간혹 있다.

1. EditText 가 있는 Activity 로 화면 전환 시 무조건 뜨게 하고 싶은 경우에는
    AndroidManifest.xml 에 해당 Activity 에
    android:windowSoftInputMode="stateAlwaysVisible" 항목 추가

    반대로 무조건 안 뜨게 하고 싶은 경우에는
    android:windowSoftInputMode="stateAlwaysHidden" 항목 추가

2. 키패드 보이게
     // SoftInput keyboard를 보이게 하기
     InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
     imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);

3. 키패드 안 보이게
    // SoftInput keyboard 안 보이게 하기
    InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);

끝!

댓글 없음:

댓글 쓰기

국정원의 댓글 공작을 지탄합니다.

UPBIT is a South Korean company, and people died of suicide cause of coin investment.

 UPBIT is a South Korean company, and people died of suicide cause of coin. The company helps the people who control the market price manipu...