Why is Android WebView refusing user input?

前端 未结 16 1868
半阙折子戏
半阙折子戏 2020-11-28 08:12

I\'m developing an Android application that uses a WebView to display the login page for Facebook. The page loads beautifully, and I\'m able to select the username/password

16条回答
  •  死守一世寂寞
    2020-11-28 08:31

    I spend a lot of time to solve this problem. Finally, I realized that it is not about WebView. In my case, I have a webview inside dialog. I want to handle back pressed button to cancel dialog and finish activity as well. And I wrote code below:

    private void setOnBackPressed() {
        this.setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    dialog.dismiss();
                    activity.finish();
                }
                return true;
            }
        });
    }
    

    So, when I use the keyboard, this method reject all key presses somehow and then it doesn't appear on the text fields.

    I only changed the return value to false. So, it worked properly.

    Hope it helps!!

    PS: this method is inside my dialog class that extends Dialog class

提交回复
热议问题