0

我正在使用以下代码在加载后在 webview 上显示软键盘。但它不起作用。任何帮助将不胜感激。

        public void onCreate(Bundle savedInstanceState) 
        {

            super.onCreate(savedInstanceState);
            super.loadUrl("file:///android_asset/www/index.html");

            InputMethodManager mgr = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);

            mgr.showSoftInput(this.appView, InputMethodManager.SHOW_IMPLICIT);

            ((InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(this.appView, 0);

            //NOTE: this code should be called after loadurl : disable the default 'save image as' and 'text selection' android dialog boxes on long clicks
            this.appView.setOnLongClickListener(new OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    return true;
                }
            });
            this.appView.setLongClickable(false);

       }
4

1 回答 1

0

在此链接中,您将找到可能会帮助您解决问题的有用信息:

http://turbomanage.wordpress.com/2012/05/02/show-soft-keyboard-automatically-when-edittext-receives-focus/

尽管作者不推荐它,但在 Manifest 中使用属性 android:windowSoftInputMode 最终可能会对您有所帮助。

于 2013-02-14T09:21:17.720 回答