NSUserDefaults.standUserDefaults().setObject(noteTitles, forKey: "note")
NSUserDefaults.standardUserDefaults().synchronize()
在onCreate()之前声明了这个:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.design.widget.TabLayout.addOnTabSelectedListener(android.support.design.widget.TabLayout$OnTabSelectedListener)' on a null object reference
和onCreate():
TabLayout.OnTabSelectedListener listener;
我很难看到侦听器是如何为空的。我有其他NullPointerExceptions甚至声称原始对象上的null对象,包括由drawable pngs定义的int?
答案 0 :(得分:1)
您忘记将布局设置为setContentView()