Populate listview after the addition of database

前端 未结 3 1737
北恋
北恋 2021-01-27 16:07

I have an app which displays data in a fragment(uses webservice). After login, fragment fetches data from json and add to database, after that I want to populate it in my fragme

相关标签:
3条回答
  • 2021-01-27 16:37

    You have to add one method in BaseAdapter for update new data:

    ArrayList<DataVal> issueList = null;
    

    Set new method setUpdatedData to assign your new Arraylist of data

     public void setUpdatedData(ArrayList<DataVal> newData){
        this.issueList = newData;
       }
    

    After set new data you have to call notifyDataSetChanged();

    adapter.notifyDataSetChanged();
    

    Done

    0 讨论(0)
  • 2021-01-27 16:45

    Change your adapter to extend ArrayAdapter and pass your list to super constructor of ArrayAdapter on initiation of your adapter class

    Also don't forget to call notifyDataSetChanged() after adding to list.

    Hope this helps.

    0 讨论(0)
  • 2021-01-27 16:54

    try to replace this line

     this.issueList = val;
    

    with

    this.issueList.clear();
    this.issueList.addAll(val);
    

    in your BaseAdapter

    0 讨论(0)
提交回复
热议问题