phoenix
phoenix copied to clipboard
kotlin.TypeCastException: null cannot be cast to non-null type android.view.ViewGroup
Caused by: kotlin.TypeCastException: null cannot be cast to non-null type android.view.ViewGroup at com.guoxiaoxing.phoenix.picker.util.ToolbarUtil.setRootView(ToolbarUtil.kt:38) at com.guoxiaoxing.phoenix.picker.util.ToolbarUtil.setColor(ToolbarUtil.kt:30) at com.guoxiaoxing.phoenix.picker.util.ToolbarUtil.setColorNoTranslucent(ToolbarUtil.kt:85) at com.guoxiaoxing.phoenix.picker.ui.picker.PickerActivity.onCreate(PickerActivity.kt:92) at android.app.Activity.performCreate(Activity.java:5312) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2552) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653) at android.app.ActivityThread.access$800(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5872) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674) at dalvik.system.NativeStart.main(Native Method)
ToolbarUtil as后面加问号 /** * 设置根布局参数 */ private fun setRootView(activity: Activity) { val rootView = (activity.findViewById<ViewGroup>(android.R.id.content) as ViewGroup).getChildAt(0) as? ViewGroup if (rootView != null) { rootView.fitsSystemWindows = true rootView.clipToPadding = true } }