package com.yuqirong.meituanlistview.adapter;

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

import com.yuqirong.meituanlistview.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Anyway on 2016/4/18.
 */
public class MAdapter extends BaseAdapter {

    private List<String> list = new ArrayList<>();

    public List<String> getList() {
        return list;
    }

    @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) {
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item, null);
        }
        TextView tv_num = (TextView) convertView.findViewById(R.id.tv_num);
        tv_num.setText(list.get(position));
        return convertView;
    }
}