How to use adapter.notifyDataSetChanged(); where i have to use these line for my error

后端 未结 2 1670
一生所求
一生所求 2020-12-02 03:17

ItemListBaseAdapter.java

public class ItemListBaseAdapter extends BaseAdapter {
private static ArrayList itemDetailsrrayList;

private I         


        
相关标签:
2条回答
  • 2020-12-02 03:40

    Don't have itemDetailsrrayList as static.

    0 讨论(0)
  • 2020-12-02 03:48

    Add this method to your adapter

    public synchronized void refresAdapter(ArrayList<Recipedetails> items) {
        itemDetailsrrayList.clear();
        itemDetailsrrayList.addAll(items);
        notifyDataSetChanged();
    }
    

    and then make this call from where you want to refresh your adapter

    final Activity act = getActivity(); //only neccessary if you use fragments
    if (act != null)
        act.runOnUiThread(new Runnable() {
            public void run() {
                yourAdapter.refreshAdapter(item);
            }
        });
    

    this should solve your problem

    0 讨论(0)
提交回复
热议问题