این روش به نسبت قدیمیه و خوب یادم نیست
اما این قطعه کد رو امتحان کنید
شاید کار کنه
public View customView(int position, @Nullable View convertView, @NonNull ViewGroup parent){
convertView= LayoutInflater.from(getContext()).inflate(R.layout.custom_spinner_layout,parent,false);
CustomItems items=getItem(position);
ImageView spinnerImage=convertView.findViewById(R.id.ivCustomSpinner);
TextView spinnerName=convertView.findViewById(R.id.tvCustomSpinner);
if (items!=null){
spinnerImage.setImageResource(items.getSpinnerImage());
spinnerName.setText(items.getSpinnerText());
}
return convertView;
}
دلیل وجود این قطعه کد رو هم متوجه نمیشم
if (spin != null){
spin.setAdapter(customAdapter);
spin.setOnItemSelectedListener(this);
}