Chris Chris - 1 month ago 12x
Android Question

Arrayadapter.getcount null point exception

I am getting the following stack trace (below is a complete copy) , this gives me little or no indication as to where in a massive application it is when going wrong and user feedback is nothing beyond "It crashed".

Is there anything I can do to pinpoint this more ?

java.lang.NullPointerException at android.widget.ArrayAdapter.getCount(
at android.widget.AdapterView.checkFocus(
at android.widget.AdapterView$AdapterDataSetObserver.onInvalidated(
at android.database.DataSetObservable.notifyInvalidated(
at android.widget.BaseAdapter.notifyDataSetInvalidated(
at android.widget.ArrayAdapter$ArrayFilter.publishResults(
at android.widget.Filter$ResultsHandler.handleMessage(
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(
at dalvik.system.NativeStart.main(Native Method)


Look at the code for ArrayAdapter.getCount():

     * {@inheritDoc}
    public int getCount() {
        return mObjects.size();

Clearly mObjects is null, i.e. your ListView or other AdapterView-derived type is trying to use the adapter before you've initialized it with it's data.