I use this in a custom view. I must admit that it doesn't always seem to
work - as reported by customers - but I've not had it fail for me in
testing on a number of devices. I actually found this doing a lot of Google
searches myself, so credit/blame goes elsewhere. While you may not need to
do all of this exactly, perhaps it will get you a little closer.
public class MyView extends LinearLayout {
<snip>
public 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
|| config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_UNDEFINED)
{
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;
}
}
}
}
Best Regards,
Eric
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en