【发布时间】:2016-10-05 05:30:32
【问题描述】:
我有一个WebView,它有一个RelativeLayout 父级。
在WebView 中,当我单击某个特定按钮时,它会加载另一个网址。我想禁用该网址上的键盘。以及我在 shouldoverrideurlloading(WebView view , Url Url) 方法中获得的那个网址。
<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>
在我做的那个方法上:
relativeLayout.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
webView.setFocusable(false);
webView.setFocusableInTouchMode(true);
但是当我点击该页面的文本字段时,仍然显示键盘。
如果我对onCreate() 活动方法执行相同的代码,它的工作正常,
但我的问题是想在我的页面加载时在 shouldOverrideUrlLoading 方法上禁用它。
【问题讨论】:
-
参考this答案
-
我已经尝试过了,所有的东西都在 oncreate 方法中工作,但我想为特定页面执行此操作,当 shouldOverrideUrlLoading 方法检测到我的 url 时。对于其他页面我想显示我的键盘,但不是那个页面。