在webview中的任何文本字段中写入时,我遇到了一个新错误。
日志中的错误消息是:
11-19 16:40:48.063:E / AndroidRuntime(24912): java.lang.IllegalArgumentException:EditText不能使用ellipsize 模式TextUtils.TruncateAt.MARQUEE
我的webview代码是:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
int i = getArguments().getInt(ARG_PLANET_NUMBER);
View rootView = (View) inflater.inflate(R.layout.webview, container,false);
// String planet =
// getResources().getStringArray(R.array.ns_menu_items)[i];
String planet = getResources().getStringArray(R.array.Links)[i];
mWebView = (WebView) rootView.findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setSaveFormData(true);
// mWebView.loadUrl("https://www.google.com/");
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
mWebView.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
if(mProgress.isShowing()) {
mProgress.dismiss();
}
}
});
mProgress = ProgressDialog.show(getActivity(), "Loading",
"Please wait for a moment...");
url = getResources().getStringArray(R.array.menu_links)[i];
mWebView.loadUrl(url);
getActivity().setTitle(planet);
return rootView;
}
对此错误有任何想法。点击任何表单元素时,应用程序崩溃。
这里是xml文件:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- The main content view -->
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
</RelativeLayout>
<!-- The navigation drawer -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ListView
android:id="@+id/drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#1BB1CC"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
activity_main.xml:
<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="@color/title_background"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
</RelativeLayout>
Webview.xml:
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:gravity="center"
>
</WebView>
答案 0 :(得分:1)
尝试添加此行
mWebView.setClickable(true);
这一行之后
mWebView = (Webiew) rootView.findViewById(R.id.webview);