public class MyProductAdapter extends BaseAdapter implements Filterable {
private Context mContext;
private final List<Product> mList;
private List<Product> mSearchList;
private LayoutInflater inflater;
public MyProductAdapter(Context context, List<Product> list) {
this.mContext = context;
this.mList = list;
this.mSearchList = new ArrayList<>(mList);
this.inflater = LayoutInflater.from(mContext);
}
/**
* 搜索框被清空后调用此方法显示所有商品
*/
public void showAllProduct() {
mSearchList = new ArrayList<>(mList);
notifyDataSetChanged();
}
@Override
public int getCount() {
return mSearchList.size();
}
@Override
public Object getItem(int position) {
return mSearchList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
BaseAdapter使用Filter笔记
最新推荐文章于 2022-09-23 15:46:42 发布