gpt4 book ai didi

android - 单击 webview 时应用程序崩溃

转载 作者:行者123 更新时间:2023-11-30 03:16:14 24 4
gpt4 key购买 nike

在 webview 中的任何文本字段中书写时,我遇到了一个新错误。

日志中的错误信息是:

11-19 16:40:48.063: E/AndroidRuntime(24912): java.lang.IllegalArgumentException: EditText cannot use the ellipsize mode 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>

最佳答案

尝试添加这一行

mWebView.setClickable(true);

在这一行之后

mWebView = (Webiew) rootView.findViewById(R.id.webview);

关于android - 单击 webview 时应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20070075/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com