3

I have a strange case, I use a webview to open a form page, which allow user to input some information in it. When I try it in some device such as Samsung, it works okay, but when I tried it in other device such as xiaomi, asus, etc it doesn't work. the keyboard popup, but when I typed it, the text box in the page just lost focus. I've found a work around using this code, but there is a down side, the webview on the samsung always go back to top each time i touch the screen (but on xiaomi, etc works okay). Is there any way to make it work for both of them?

        mPaymentWebView.getSettings().setJavaScriptEnabled(true);
        mPaymentWebView.getSettings().setUseWideViewPort(true);
        mPaymentWebView.requestFocus(View.FOCUS_DOWN);
        mPaymentWebView.requestFocusFromTouch();

        mPaymentWebView.requestDisallowInterceptTouchEvent(true);
        mPaymentWebView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent event) {
                Log.d("test keyboard","in");
                mPaymentWebView.requestFocusFromTouch(); //this makes it work
                return false;
            }
        });

and this is the XML

 <FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <WebView
        android:id="@+id/web_view_payment"
        android:focusableInTouchMode="true"
        android:windowSoftInputMode="adjustResize"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </WebView>
    <ProgressBar
        style="?android:attr/progressBarStyleHorizontal"
        android:id="@+id/progress_bar_webview"
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:layout_alignParentBottom="true"
        android:progress="5"
        android:max="100"
        android:progressDrawable="@drawable/progress_bar" />

</FrameLayout>

I've used all the answer from this question but none of them works properly Why is Android WebView refusing user input?

Community
  • 1
  • 1
stephen1706
  • 1,010
  • 11
  • 22
  • possible duplicate of [Why is Android WebView refusing user input?](http://stackoverflow.com/questions/2083909/why-is-android-webview-refusing-user-input) – Maveňツ Dec 23 '14 at 08:16
  • @maveň I've used all the answer there but as I said, none of them works properly for all of android devices – stephen1706 Dec 23 '14 at 08:27

1 Answers1

0

Please check if Android System WebView is installed. If so uninstall the updates by going into the Settings->Apps->Android System Webview->Uninstall Updates

Abilash
  • 104
  • 1
  • 10