-5

I want to refresh BaseAdapter which is in fragment. I am showing bluetooth list using BaseAdapter. I want to refresh this list on Refresh button click and want show on Listview in Fragment . What should I do for this?

UltimateDevil
  • 2,807
  • 2
  • 18
  • 31
Shekhar Jadhav
  • 1,035
  • 9
  • 20
  • 2
    Simply try to use notifyDataSetChanged() to notify the adapter to refresh the listvew. – yash786 Oct 13 '17 at 05:53
  • 4
    Possible duplicate of [How to refresh Android listview?](https://stackoverflow.com/questions/2250770/how-to-refresh-android-listview) – AskNilesh Oct 13 '17 at 05:58

2 Answers2

2

Try this .

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(); 
}
...

When click

mAdapter.refresh(mList); 
KeLiuyue
  • 8,149
  • 4
  • 25
  • 42
0

Update your data collection, such as Array or List, and do BaseAdapter.notifyDataSetChanged();

RRTW
  • 3,160
  • 1
  • 35
  • 54