我正在尝试使用自己的自定义MvxListView
向MvxAdapter
添加页眉和页脚。
从一个Activity,我可以在OnCreate()
方法中将适配器添加到listview,它就可以了。
但如果我尝试从片段中的OnCreateView()
尝试相同的操作,我会得到一个Java.Lang.RuntimeException
,其中包含以下堆栈跟踪:
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod) [0x00000] in <filename unknown>:0
at Android.Widget.BaseAdapter.NotifyDataSetChanged () [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Binding.Droid.Views.MvxAdapter.NotifyDataSetChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Binding.Droid.Views.MvxAdapter.OnItemsSourceCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of managed exception stack trace ---
java.lang.NullPointerException
at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
at mono.java.lang.RunnableImplementor.n_run(Native Method)
at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
我在这里错过了什么吗?
谢谢!