package com.bbitcn.silk.ui.view;

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

import androidx.annotation.NonNull;

import com.bbitcn.silk.R;

/**
 * 自定义下拉框适配器
 */
public class CustomSpinnerAdapter extends ArrayAdapter<String> {

    public CustomSpinnerAdapter(Context context, String[] items) {
        super(context, R.layout.item_list, items);
    }

    @NonNull
    @Override
    public View getView(int position, View convertView, @NonNull ViewGroup parent) {
        View view = convertView;
        if (view == null) {
            LayoutInflater inflater = LayoutInflater.from(getContext());
            view = inflater.inflate(R.layout.item_list, parent, false);
        }

        // 获取布局中的TextView和ImageView
        TextView textView = view.findViewById(R.id.tv);

        // 设置TextView和ImageView的内容
        textView.setText(getItem(position));

        return view;
    }
}
