Show soft keyboard in AlertDialog with a WebView inside (Android)

后端 未结 3 1997
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-10 02:36

In my Android app I create an AlertDialog that has a WebView inside. The WebView loads a webpage that requires the user to log in. How

3条回答
  •  一整个雨季
    2020-12-10 03:22

    It seems that the best solution is to simply create a custom dialog. Custom dialogs do not appear to have the soft keyboard bug at all (it shows up exactly when it has to). Here's some basic code:

    Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setContentView(R.layout.dialog);
    dialog.setTitle("My great title");
    dialog.setCancelable(true);
    
    dialog.show();
    dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.icon);
    
    WebView vw = (WebView) dialog.findViewById(R.id.wv);
    

提交回复
热议问题