Row item color jumps to another row everytime I scroll the listview

时间:2016-04-12 00:40:41

标签: android listview

I have a situation that everytime I scroll the listview the color of a certain row goes to the another row.

Here's my code.

@Override
    public View getView(int position, View view, ViewGroup viewGroup) {

        final int pos = position;
        final ViewHolder holder;

        if (view == null) {
            inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = inflater.inflate(R.layout.list_admin, viewGroup, false);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        if (data.get(pos).getDateEntry().length() > 0) {
            view.setBackgroundResource(R.color.SeaGreen);
        }

        return view;
    }

0 个答案:

没有答案