PractiveWrongAdapter.java 1.4 KB
package com.hh.xuetubao.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hh.xuetubao.R;
import com.hh.xuetubao.bean.AnswerBean;

import java.util.List;

public class PractiveWrongAdapter extends BaseAdapter {
    private List<AnswerBean.CatalogLstBean> list;
    private Context context;

    public PractiveWrongAdapter(List<AnswerBean.CatalogLstBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.lv_practice_wrong, null);
        TextView title = (TextView) view.findViewById(R.id.title);
        TextView count = (TextView) view.findViewById(R.id.count);

        count.setText(String.valueOf(list.get(position).getWrongNum()));
        if (list.get(position).getCatalogName() != null)
            title.setText(list.get(position).getCatalogName());
        return view;
    }
}