Android 当我使用webview添加带有一个片段的选项卡布局时,应用程序停止

Android 当我使用webview添加带有一个片段的选项卡布局时,应用程序停止,android,android-layout,android-studio,android-fragments,logcat,Android,Android Layout,Android Studio,Android Fragments,Logcat,LOGCAT错误报告 02-20 10:46:13.344 7295-7295/seacoders.abhilash.bogguru E/dalvikvm: Could not find class 'android.support.v4.widget.DrawerLayout$1', referenced from method android.support.v4.widget.DrawerLayout.<init> 02-20 10:46:13.352 7295-7295/s

LOGCAT错误报告

02-20 10:46:13.344 7295-7295/seacoders.abhilash.bogguru E/dalvikvm: Could not find class 'android.support.v4.widget.DrawerLayout$1', referenced from method android.support.v4.widget.DrawerLayout.<init>

02-20 10:46:13.352 7295-7295/seacoders.abhilash.bogguru E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method android.support.v4.widget.DrawerLayout.onDraw

02-20 10:46:13.354 7295-7295/seacoders.abhilash.bogguru E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method android.support.v4.widget.DrawerLayout.onMeasure

02-20 10:46:13.356 7295-7295/seacoders.abhilash.bogguru E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method android.support.v4.widget.DrawerLayout.onMeasure

02-20 10:46:13.424 7295-7295/seacoders.abhilash.bogguru E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering

02-20 10:46:14.055 7295-7295/seacoders.abhilash.bogguru E/AndroidRuntime: FATAL EXCEPTION: main
                                                                          java.lang.NullPointerException
                                                                              at seacoders.abhilash.bogguru.HomeFragment$MyWebViewClient.onPageStarted(HomeFragment.java:55)
                                                                              at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:331)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                              at android.os.Looper.loop(Looper.java:194)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5371)
                                                                              at java.lang.reflect.Method.invokeNative(Native Method)
                                                                              at java.lang.reflect.Method.invoke(Method.java:525)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                                                                              at dalvik.system.NativeStart.main(Native Method)

下面的问题

   pbar = (ProgressBar) container.findViewById(R.id.pg1);
   txt = (TextView) container.findViewById(R.id.txtload);
container
上调用
findViewById
方法,应该调用
v
而不是
container

解决方案

   pbar = (ProgressBar) v.findViewById(R.id.pg1);
   txt = (TextView) v.findViewById(R.id.txtload);

谢谢

可能会重复显示您的xml。第55行有什么内容。可能
pbar
txt
为空。将视图ID与布局xml匹配。pbar&txt不是null已在fragment_home.xml中声明,非常感谢
   pbar = (ProgressBar) v.findViewById(R.id.pg1);
   txt = (TextView) v.findViewById(R.id.txtload);