GridAdapter java.lang.NullPointerException

时间:2014-05-30 06:03:53

标签: android gridview android-asynctask

我有java.lang.NullPointerException,但我不知道问题出在哪里。

此错误来自Google Play控制台。

知道这是什么问题吗?

java.lang.NullPointerException
at pl.test.griditem.GridAdapter.<init>(GridAdapter.java:33)
at pl.test.griditem.ArticlesGridFragment.methodThatDoesSomethingWhenTaskIsDone(ArticlesGridFragment.java:131)
at pl.test.griditem.ArticlesGridFragment.access$0(ArticlesGridFragment.java:127)
at pl.test.griditem.ArticlesGridFragment$1.onTaskDone(ArticlesGridFragment.java:111)
at pl.test.AsyncDownloadData.onPostExecute(AsyncDownloadData.java:66)
at pl.test.AsyncDownloadData.onPostExecute(AsyncDownloadData.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:602)
at android.os.AsyncTask.access$600(AsyncTask.java:156)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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:817)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)

这是我的代码:

private void methodThatDoesSomethingWhenTaskIsDone(RssFeed rssFeed) {               
        ArrayList<RssItem> items = rssFeed.getRssItems();
        GridAdapter newsGridAdapter = new GridAdapter(getActivity(), items);

        if(gridview != null) {
            gridview.setAdapter(newsGridAdapter);
            gridview.setSelection(list_position);
        }       
    }

1 个答案:

答案 0 :(得分:0)

如果rssFeed参数对此方法为空,则会发生这种情况。