How is it right to release evaporative data on the listview, cardview, list?



  • There's a set of hard data. ArrayList<String> stringswhich we get through some web page. Parsing is naturally taking place in a separate flow, but when I try to get these data out of here, cardview or simply listview No data come. The data will only be decorated if you can force the main flow to wait for the side. There you go.

    try {
            strings = stringsTask.get();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    

    How can you avoid such a design? I'm guessing we need to go to school. onPostExecute() I don't know what. As indicated there MainActivity.adapter.notifyDataSetChanged(); not working (i.e. after full download of all data, data are still not updated). I tried to explain my problem, but if I couldn't, please write about it.



    1. Don't do an adapter with a static field.
    2. Your data come as an argument. That's what you need to do with them,
    3. Get him. ListView or RecyclerView or something.
    4. Now you can call. notifyDataSetChanged() above the adapter.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2