IndexOutOfBoundException on filtering SimpleAdapter

前端 未结 2 354
一整个雨季
一整个雨季 2021-01-21 10:05

I sub classed SimpleAdapter to add some extra functionality to it, like changing background color, custom views and filtering. The background thing is working out g

2条回答
  •  被撕碎了的回忆
    2021-01-21 10:44

    No need to add filter and bindView methods, only make sure for getView:

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = super.getView(position, convertView, parent);
    
        if(position%2!=0) {
            v.setBackgroundColor(Color.DKGRAY);
        }
        else {
            v.setBackgroundColor(Color.BLACK);
        }
    
        return v;
    }
    

提交回复
热议问题