java.lang.NullPointerException when invoking onLoadFinished()
This question already has an answer here:
Because you are creating ProductCursorAdapter mCursorAdapter
within the context of the class but initializing another local variable instead of that one in your onCreate
. Here is the problematic line:
ProductCursorAdapter mCursorAdapter = new ProductCursorAdapter(this, null);
which should be:
mCursorAdapter = new ProductCursorAdapter(this, null);
In onCreate()
instead of:
ProductCursorAdapter mCursorAdapter = new ProductCursorAdapter(this, null);
Do:
mCursorAdapter = new ProductCursorAdapter(this, null);
You are creating a local variable inside onCreate()
, thus the field on your class remains uninitialized.
上一篇: 关于装饰模式和抽象装饰类的问题?