0

我已经尝试使用以下代码在应用程序加载后立即显示软键盘,并借助此url中的代码,但软键盘不显示。不知道我做错了什么。

public class MainActivity extends DroidGap {    

        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) 
        {
            super.onCreate(savedInstanceState);
            //KeyBoard keyboard = new KeyBoard(this, appView);
           // appView.addJavascriptInterface(keyboard, "KeyBoard");
            super.loadUrl("file:///android_asset/www/index.html");
            InputMethodManager mgr = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
            // only will trigger it if no physical keyboard is open
            mgr.showSoftInput(appView, InputMethodManager.SHOW_IMPLICIT);

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

         }

}
4

0 回答 0