On a phone with a physical keyboard:
- if keyboard is not hidden don't bring up the soft keyboard.
- if the keyboard is hidden, need to do the SHOW_FORCED option which
is handled in the ResultReceiver class.
- depending on how you exit, it may leave the keyboard up - not
desirable, so I might try to address this.
On a phone without a physical keyboard:
- SHOW_IMPLICIT seems to work nicely and the keyboard doesn't stay up
when you exit the application.
View.OnLongClickListener mLongClickListener = new
View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
softKeyboardResults rr = new softKeyboardResults();
Configuration config = MyView.this.getResources().getConfiguration
();
if (config.hardKeyboardHidden ==
Configuration.HARDKEYBOARDHIDDEN_YES) {
InputMethodManager imm = (InputMethodManager)
MyView.this.mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(MyView.this, InputMethodManager.SHOW_IMPLICIT,
rr);
}
return false;
}
};
class softKeyboardResults extends ResultReceiver {
public softKeyboardResults() {
super(getHandler());
}
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
super.onReceiveResult(resultCode, resultData);
switch (resultCode) {
case InputMethodManager.RESULT_HIDDEN:
case InputMethodManager.RESULT_SHOWN:
case InputMethodManager.RESULT_UNCHANGED_SHOWN:
break;
case InputMethodManager.RESULT_UNCHANGED_HIDDEN:
InputMethodManager imm = (InputMethodManager)
MyView.this.mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(MyView.this, InputMethodManager.SHOW_FORCED);
break;
default:
break;
}
}
}
댓글 없음:
댓글 쓰기