我有主要的“tabHost”布局,它的框架内容设置在另一个包含 webview 的布局“内容”上。“Tabbar”类设置tabhost布局,“second”类设置其框架内容。
问题是,当我从“Tabbar”类中尝试使用以下在参数上崩溃的代码来设置 webview 高度时,
WebView webviewA = (WebView) findViewById(R.id.webviewA);
LayoutParams params = (LayoutParams) webviewA.getLayoutParams();
params.height -= 300;
已经尝试从 Tabbar 调用 webviewA 的函数,
标签栏类
second recalcula = new second();
recalcula.recalcula();
二等
public void recalcula (){
webviewA = (WebView) findViewById(R.id.webviewA);
LayoutParams params = (LayoutParams) webviewA.getLayoutParams();
params.height -= 300;
webviewA.setLayoutParams(params);
}
在参数上也崩溃了......我做错了什么?谢谢你。
日志错误
07-06 10:14:39.893: E/AndroidRuntime(11023): FATAL EXCEPTION: main
07-06 10:14:39.893: E/AndroidRuntime(11023): java.lang.NullPointerException
07-06 10:14:39.893: E/AndroidRuntime(11023): at com.xxxxx.projecte1.second.recalcula(second.java:70)
07-06 10:14:39.893: E/AndroidRuntime(11023): at com.xxxxx.projecte1.TabBar.onReceiveAd(TabBar_iOSActivity.java:493)
07-06 10:14:39.893: E/AndroidRuntime(11023): at com.google.ads.internal.d.B(SourceFile:1116)
07-06 10:14:39.893: E/AndroidRuntime(11023): at com.google.ads.internal.c$e.run(SourceFile:187)
07-06 10:14:39.893: E/AndroidRuntime(11023): at android.os.Handler.handleCallback(Handler.java:587)
07-06 10:14:39.893: E/AndroidRuntime(11023): at android.os.Handler.dispatchMessage(Handler.java:92)
07-06 10:14:39.893: E/AndroidRuntime(11023): at android.os.Looper.loop(Looper.java:138)
07-06 10:14:39.893: E/AndroidRuntime(11023): at android.app.ActivityThread.main(ActivityThread.java:3701)
07-06 10:14:39.893: E/AndroidRuntime(11023): at java.lang.reflect.Method.invokeNative(Native Method)
07-06 10:14:39.893: E/AndroidRuntime(11023): at java.lang.reflect.Method.invoke(Method.java:507)
07-06 10:14:39.893: E/AndroidRuntime(11023): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
07-06 10:14:39.893: E/AndroidRuntime(11023): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
07-06 10:14:39.893: E/AndroidRuntime(11023): at dalvik.system.NativeStart.main(Native Method)