package com.wdkl.lcd_board.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.wdkl.lcd_board.R;

public class NumAdapter extends BaseAdapter {
    private String[] num;
    private Context context;

    public NumAdapter(String[] numbers, Context context) {
        this.num = numbers;
        this.context = context;
    }


    @Override
    public int getCount() {
        return num.length;
    }

    @Override
    public Object getItem(int position) {
        return num[position];
    }

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.digital_item, null);
            viewHolder = new ViewHolder();
            viewHolder.numTv = convertView.findViewById(R.id.tv_number);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.numTv.setText(num[position]);

        return convertView;
    }

    static class ViewHolder {
        TextView numTv;
    }
}
