Setting up async task for loading Json into a listview

前端 未结 5 1723
予麋鹿
予麋鹿 2020-12-09 23:22

I take json object generate from a PHP script on my server and then parse it into a listview using a lazy load for the images. The problem is that the json will load relativ

5条回答
  •  臣服心动
    2020-12-09 23:50

    Once you have your asynctask running successfully, it might be worth your while to change your listview to use fragments instead. In doing so, you get a nice spinning progress wheel if the list's adapter is currently empty. This happens when you use the default list view item, or including the list_content layout in your custom layout.

    Best way to do this is create your activty, start your asynctask and in the task's onpostexecute method, set the listfragment's adapter up. This way you'll get a nice loading screen while your data is downloaded.

    See: http://developer.android.com/reference/android/app/ListFragment.html#setListShown(boolean)

提交回复
热议问题