在此代码中,我要在保存按钮单击时刷新我的自定义列表视图

问题描述 投票:0回答:1

下面列出了我想要的代码。

  1. 此方法不会在单击按钮时刷新列表视图。

    public synchronized void refresAdapter(ArrayList<ManageCuisineHelper> dataitems) {
    
        notifyDataSetChanged();
    }
    
java android
1个回答
0
投票

您没有在Adapter类的refreshAdapter方法中更新最新数据。像下面那样更改方法主体,它应该对您有用。

public synchronized void refresAdapter(ArrayList<ManageCuisineHelper> dataitems) {
        if(this.list_data != null) {
          this.list_data.clear();
          this.list_data = dataitems;
          notifyDataSetChanged();
       }
    }
© www.soinside.com 2019 - 2024. All rights reserved.