dynamic lazylist

后端 未结 3 1045
甜味超标
甜味超标 2021-01-23 12:51

Hello everyone i want to make this Lazylist dynamic . i have tried with images first buts its coming with force to close . Please guide if my approach is wrong. Here is code

相关标签:
3条回答
  • 2021-01-23 13:16
    list.setAdapter(adapter);
    

    According to your output, that line is erroring saying that something (your mStrings variable) is null when it tried to getCount() from it.

    Try instead moving that line to after you have gathered data on mStrings.

    You will want to consider setting it to an empty String[] then having it load the data on a background thread, then adding items through another method at the completion of the download.

    0 讨论(0)
  • 2021-01-23 13:24

    Before using LazyAdapter you should have some data to be displayed. I think right now you don't have correct data. I guess mStrings is null. I guess because there's something wrong with your download/parse code. So please debug your parse code to ensure it works fine. Please ensure mStrings has correct data.

    Also you don't need to use LazyAdapter. You should have your own adapter that displays your data. But inside your adapter you can use ImageLoader.displayImage() method like I do in LazyAdapter.

    0 讨论(0)
  • 2021-01-23 13:30

    Your NullPointer Exception is in getCount() line 27:

    Caused by: java.lang.NullPointerException
    at com.droidnova.android.howto.optionmenu.LazyAdapter.getCount(LazyAdapter.java:27)
    

    You could fix the sympton by changing getCount() to:

    public int getCount() {
        if(data != null){
            return data.length;
        }
        return 0;
    }
    
    0 讨论(0)
提交回复
热议问题