2

I have one WebView which has a RelativeLayout parent. in WebView when i click on some specific button, it loads another url. i want to disable keyboard on that url. and that url i got in shouldoverrideurlloading(WebView view , Url Url) method.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background"
    android:gravity="center_horizontal"
    android:orientation="vertical"
    tools:context="com.xenopsi.benchmark.BrowserActivity">

    <WebView
        android:id="@+id/browserView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:scrollbars="none"/>

   </RelativeLayout>

On that method i did:

relativeLayout.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
webView.setFocusable(false);
webView.setFocusableInTouchMode(true);

but still when i tap on text field of that page , keyboard still shown. if i did same code on onCreate() method of activity, its work fine,

but my problem is want to disable it on shouldOverrideUrlLoading method when my page load.

V-rund Puro-hit
  • 5,270
  • 8
  • 27
  • 48
ankur
  • 51
  • 6
  • refer [this](http://stackoverflow.com/a/30440309/5148289) answer – V-rund Puro-hit Oct 05 '16 at 05:40
  • i already tried that , all the things working in oncreate method , but i want to do this for a specific page, when shouldOverrideUrlLoading method detect my url. for other page i want to show my keyboard , but not for that page. – ankur Oct 05 '16 at 05:52

1 Answers1

0

Okey as you mention you want to hide keyboard for particular link, do something like this,

public boolean shouldOverrideUrlLoading(WebView view, String url) {
    Log.e("Loading URL", url);

    view.loadUrl(url);

    if(url.equals(yourUrl)){
        // hide keyboard
    } else {
        // unhide keyboard
    }
    return true;
}

I hope this will Help..

Happy Coding..

V-rund Puro-hit
  • 5,270
  • 8
  • 27
  • 48