Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot insert text into webview that is on a tab
    primarykey
    data
    text
    <p>I have two tabs and each of them contains a webview (with google page, for sake of simplicity). The web view loads fine, but when I try to insert some text into Google's search field, the soft keyboard appears as expected, but if I start writing some text, the field loses focus. It seems that it considers soft keyboard as part of the tab layout and not of the webpage layout.</p> <p>I've spent hours trying all the solutions I've found, but any of them worked in my case. For instance: <a href="https://stackoverflow.com/questions/2083909/why-is-android-webview-refusing-user-input">Why is Android WebView refusing user input?</a> and <a href="https://stackoverflow.com/questions/2653923/cant-type-inside-a-web-view">Can&#39;t type inside a Web View</a></p> <p>Any other idea is really welcome! I think that all the relevant code is posted below, otherwise just ask.</p> <p>Thanks!</p> <p>MainActivity.java (FragmentActivity)</p> <pre><code>public void onTabChanged(String selected) { Fragment shownFragment = fm.findFragmentByTag(shown); FragmentTransaction ft = fm.beginTransaction(); // Remove the current fragment from screen if (shownFragment != null) { ft.remove(shownFragment); } // Change to the new fragment if (selected.equals("Tab1")) { shown = "Tab1"; ft.add(R.id.fragment_content, new WebFragment(), "Tab1"); } else if (selected.equals("Web")) { shown = "Web"; ft.add(R.id.fragment_content, new WebFragment(), "Web"); } ft.commit(); } </code></pre> <p>WebFragment.java</p> <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { webView = (WebView) inflater.inflate(R.layout.activity_web_fragment, container, false); webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl("http://www.google.com"); webView.setWebViewClient(new MyWebViewClient()); Log.v("WebFragment", "Returning web view"); webView.requestFocus(View.FOCUS_DOWN); return webView; } private class MyWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } @Override public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) { if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK) &amp;&amp; view.canGoBack()) { view.goBack(); return true; } return super.shouldOverrideKeyEvent(view, event); } } </code></pre> <p>activity_main.xml</p> <pre><code>&lt;LinearLayout android:id="@+id/LinearLayout1" android:orientation="vertical" 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"&gt; &lt;TabHost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="2dp"&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;HorizontalScrollView android:id="@+id/hScrollView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:fillViewport="true" android:scrollbars="none"&gt; &lt;TabWidget android:id="@android:id/tabs" android:layout_width="wrap_content" android:layout_height="wrap_content" android:tabStripEnabled="true"/&gt; &lt;/HorizontalScrollView&gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="0" /&gt; &lt;FrameLayout android:id="@+id/fragment_content" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; </code></pre> <p></p> <p>activity_web_fragment.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;WebView android:id="@+id/webView" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload