There is such an adapter. do in activi

mAdapter.clear(); mAdapter.notifyDataSetChanged(); 

Just nothing happens.

Adapter code:

 public class FilesAdapter extends ArrayAdapter<FilesInfo> { private ArrayList<FilesInfo> mObjects; private Context mContext; private View mConvertView; private ViewGroup mParent; public FilesAdapter(Context _context, ArrayList<FilesInfo> _objects) { super(_context, R.layout.c_files_list_view); mContext = _context; mObjects = _objects; } @Override public int getCount() { return mObjects.size(); } @Override public View getView(int _position, View _convertView, ViewGroup _parent) { LayoutInflater mInflater = (LayoutInflater) mContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE); mConvertView = _convertView; mParent = _parent; if (mConvertView == null) { mConvertView = mInflater.inflate(R.layout.c_files_list_view, mParent, false); } ((ImageView) mConvertView.findViewById(R.id.list_icon)).setImageDrawable(mObjects.get(_position).getIcon()); ((TextView) mConvertView.findViewById(R.id.list_name)).setText(mObjects.get(_position).getName()); ((TextView) mConvertView.findViewById(R.id.list_size)).setText(Double.toString(mObjects.get(_position).getSize())); return mConvertView; } 
  • Resolved by overriding some more methods from the parent class! - denqxotl
  • ArrayList<FilesInfo> _objects , not Adapter - tim_taller

2 answers 2

  1. Better to use BaseAdaper
  2. if it’s not better, then we need to understand that the ArrayAdapter has its own ArrayList, which is cleared when mAdapter.clear ();
  3. it would be nice not to forget about the ViewHolder pattern
  • Explain, please, what is the advantage of BaseAdapter'a over ArrayAdapter'om ?. I will get acquainted with the pattern now. Thank! - denqxotl
  • one
    The @denqxotl advantage is that the ArrayAdapter is inherited from the BaseAdapter, and contains a lot of everything that you do not use. In fact, you do not use the ArrayAdapter functionality in your adapter, but use only the BaseAdapter - Vladyslav Matviienko

Be sure to read the Android Adapter Good Practices .