首页 > 代码库 > Android在ArrayAdapter<>里如何得到List<>的Items

Android在ArrayAdapter<>里如何得到List<>的Items

public class ItemAdapter extends ArrayAdapter<DemoModel> {    private final List<DemoModel> items;public AnswerItemAdapter(Context c, List<DemoModel> items) {        super(c, 0, items);        this.items = items;    }    @Override    public View getView(int position, View convertView, ViewGroup parent) {    //Do something...
return convertView; } public List<DemoModel> getItems() { return items; }}

当前,也可以使用list.clone()也克隆一份list。

然后在Activity里通过 adapter来获取items。

        List<ModeModel> items=ItemAdapter.getItems();