gpt4 book ai didi

用于 webview 的 android setLayoutParams 生成错误

转载 作者:太空宇宙 更新时间:2023-11-03 11:53:13 25 4
gpt4 key购买 nike

是否可以设置

mWebView = (WebView) findViewById(R.id.webviewHelp);
mWebView.setLayoutParams(new ViewGroup.LayoutParams(100, 200));

这里

 mWebView.setLayoutParams(new Gallery.LayoutParams(70,85));

也经过测试但无法正常工作:(

在我的 Activity 中?我的 xml 文件如下所示

(我的应用程序需要通过 XML 创建 webview)

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:id="@+id/rl"
android:layout_height="360dip">
<!-- <WebView android:id="@+id/webviewHelp" android:layout_width="fill_parent"-->
<!-- android:layout_height="fill_parent" />-->
<WebView android:id="@+id/webviewHelp" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<Button android:id="@+id/My_btn"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" android:gravity="center" android:textSize="8px" android:text="Download this mp3 file"
android:textColor="@color/white"
android:layout_width="fill_parent" android:layout_height="33dip"
android:visibility="invisible" />
<Button android:id="@+id/My_btn1"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" android:text="this is button !"
android:layout_width="0dip" android:layout_height="0dip"
android:visibility="invisible" />
</RelativeLayout>

我收到此错误并强制关闭应用程序

06-11 15:42:51.816: DEBUG/AndroidRuntime(323): Shutting down VM
06-11 15:42:51.816: WARN/dalvikvm(323): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
06-11 15:42:51.816: ERROR/AndroidRuntime(323): Uncaught handler: thread main exiting due to uncaught exception
06-11 15:42:51.835: ERROR/AndroidRuntime(323): java.lang.ClassCastException: android.view.ViewGroup$LayoutParams
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.RelativeLayout$DependencyGraph.findRoots(RelativeLayout.java:1291)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1238)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:279)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:299)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.View.measure(View.java:7703)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.View.measure(View.java:7703)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.View.measure(View.java:7703)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.View.measure(View.java:7703)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:569)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:361)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.View.measure(View.java:7703)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.View.measure(View.java:7703)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.View.measure(View.java:7703)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.LinearLayout.measureVertical(LinearLayout.java:464)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.View.measure(View.java:7703)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.View.measure(View.java:7703)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.ViewRoot.performTraversals(ViewRoot.java:747)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.view.ViewRoot.handleMessage(ViewRoot.java:1613)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.os.Handler.dispatchMessage(Handler.java:99)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.os.Looper.loop(Looper.java:123)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at android.app.ActivityThread.main(ActivityThread.java:4203)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at java.lang.reflect.Method.invokeNative(Native Method)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at java.lang.reflect.Method.invoke(Method.java:521)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
06-11 15:42:51.835: ERROR/AndroidRuntime(323): at dalvik.system.NativeStart.main(Native Method)
06-11 15:42:51.845: INFO/Process(52): Sending signal. PID: 323 SIG: 3
06-11 15:42:51.845: INFO/dalvikvm(323): threadid=7: reacting to signal 3
06-11 15:42:51.857: ERROR/dalvikvm(323): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
06-11 15:42:52.566: DEBUG/dalvikvm(99): GC freed 4505 objects / 251696 bytes in 293ms

我做错了什么?提前致谢:Pragna

最佳答案

取而代之的是:

   mWebView = (WebView) findViewById(R.id.webviewHelp);    
mWebView.setLayoutParams(new ViewGroup.LayoutParams(100, 200));

使用:

   mWebView = (WebView) findViewById(R.id.webviewHelp);        
LayoutParamters lp = mWebView.getLayoutParams();
lp.width=100;
lp.height=200;
mWebView.setLayoutParams(lp);

关于用于 webview 的 android setLayoutParams 生成错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6315331/

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