Android 如何在单击“刷新”按钮时刷新BaseAdapter
我想刷新片段中的BaseAdapter。我正在使用BaseAdapter显示蓝牙列表。我想在“刷新”按钮单击时刷新此列表,并希望在Listview中显示片段。Android 如何在单击“刷新”按钮时刷新BaseAdapter,android,Android,我想刷新片段中的BaseAdapter。我正在使用BaseAdapter显示蓝牙列表。我想在“刷新”按钮单击时刷新此列表,并希望在Listview中显示片段。 我应该为此做些什么?更新您的数据收集,如数组或列表,然后尝试此操作 public class PersonAdapter extends BaseAdapter { private ArrayList<PersonBean> mList; private Context mContext; public PersonA
我应该为此做些什么?更新您的数据收集,如数组或列表,然后尝试此操作
public class PersonAdapter extends BaseAdapter {
private ArrayList<PersonBean> mList;
private Context mContext;
public PersonAdapter(ArrayList<PersonBean> list, Context context) {
mList = list;
mContext = context;
}
public void refresh(ArrayList<PersonBean> list) {
mList = list;
notifyDataSetChanged();
}
...
只需尝试使用notifyDataSetChanged通知适配器刷新listvew。可能的重复项
mAdapter.refresh(mList);