package com.tofly.ghrq_route.common.util;

import android.content.Context;
import android.widget.ArrayAdapter;

import androidx.appcompat.widget.AppCompatSpinner;

import com.tofly.ghrq_route.R;

import java.util.List;

/**
 * @author ychk
 * 下拉列表工具类
 */
public class SpinnerUtils {

    public static void setAdapter(Context context, AppCompatSpinner spinner, String[] aar) {
        ArrayAdapter<String> buildTypeAdapter = new ArrayAdapter<>(context, R.layout.my_simple_spinner_item, aar);
        buildTypeAdapter.setDropDownViewResource(R.layout.danger_report_spinner_item);
        spinner.setAdapter(buildTypeAdapter);
    }

    public static void setAdapter(Context context, AppCompatSpinner spinner, List<String> aar) {
        ArrayAdapter<String> buildTypeAdapter = new ArrayAdapter<>(context, R.layout.my_simple_spinner_item, aar);
        buildTypeAdapter.setDropDownViewResource(R.layout.danger_report_spinner_item);
        spinner.setAdapter(buildTypeAdapter);
    }

    public static void setTextForSpinner(Context context, AppCompatSpinner spinner, String NewName) {
        String[] items = {NewName};
        ArrayAdapter<String> adapter = new ArrayAdapter<>(context, R.layout.my_simple_spinner_item, items);
        spinner.setAdapter(adapter);
    }
}
