Why is Android WebView refusing user input?

前端 未结 16 1866
半阙折子戏
半阙折子戏 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:29

    In my case TabHost from a previous fragment in back stack was stealing the focus from WebView input on every key press. Here's how I fixed it:

    tabHost.addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
      @Override
      public void onViewDetachedFromWindow(View v) {}
    
      @Override
      public void onViewAttachedToWindow(View v) {
        tabHost.getViewTreeObserver().removeOnTouchModeChangeListener(tabHost);
      }
    });
    

    See https://code.google.com/p/android/issues/detail?id=2516 for more on the topic.

提交回复
热议问题