package com.example.leudaemialikeme.Adapter;

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

import com.example.leudaemialikeme.R;

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

public class AdapterClock extends BaseAdapter {

    private String[] names={"甘露聚糖肽胶囊","消癌平糖浆"};
    private String[] time={"每天  8:00  14:00  19:00","每天  8:00  14:00  19:00"};
    private List<Switch> list_switch;

    private Context mContext;

    private TextView tv1,tv2;
    private Switch aSwitch;

    public AdapterClock(Context context) {
        mContext=context;
        list_switch=new ArrayList<>();
    }


    public Switch getaSwitch(int position){

        return list_switch.get(position);
    }

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

    @Override
    public Object getItem(int i) {
        return names[i];
    }

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

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

        view= LayoutInflater.from(mContext).inflate(R.layout.list_item,null);
        tv1=(TextView)view.findViewById(R.id.md_name);
        tv2=(TextView)view.findViewById(R.id.md_time);
        aSwitch=(Switch)view.findViewById(R.id.sw);

        list_switch.add(aSwitch);

        tv1.setText(names[i]);
        tv2.setText(time[i]);


        return view;
    }
}
