How to update listview when back pressed from another activity android?

前端 未结 3 1947
北海茫月
北海茫月 2021-01-18 09:48

Hi how to update listView when back pressed in another activity. I am using database, where i am deleting particular row in one Activity, if back p

3条回答
  •  感情败类
    2021-01-18 10:41

    First write below method in Adapter

        public void updateList(List mChatDetails) {
        this.mChatDetails.clear();
        this.mChatDetails.addAll(mChatDetails)
    }
    

    In resume fetch the data from database and call updateList(List mChatDetails) method then call notifyDatasetChanged()

        @Override
    public void onResume() {
        // fetch updated data
        adapter.updateList(mChatDetails);
        adapter.notifyDataSetChanged();
    }
    

提交回复
热议问题