Java.lang.IllegalStateException: The application PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged android

前端 未结 6 1552
花落未央
花落未央 2021-02-08 10:00

I am trying to use a static class to pass value to a view instead of using intent as I have to pass a large amount of data. Sometimes I get this error and couldn\'t find out wha

6条回答
  •  抹茶落季
    2021-02-08 10:27

    I think your DataResult class is not necessary.

    According to your comment you are getting the error while you are updating the data set. I think you are getting data from some REST API or another web service. Then assign the data you gets from the API to a temporary Array List and update that temporary array list while you are getting new data. Don't touch the mListA variable until you finish receiving data. After complete getting data from the API assign the temporary array list you used to mListA directly in one line.

    mListA = tmpList;
    

    Then again call

    mList = mListA;
    pagerAdapter.notifyDataSetChanged();
    

    This should solve your error.

提交回复
热议问题