package ta1.cis.adapter

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 ta1.cis.R
import ta1.cis.model.staticdata.ProdiData

class SpinnerProdiAdapter(context: Context, resource: Int, prodilist: MutableList<ProdiData>) :
    ArrayAdapter<ProdiData>(context, resource, prodilist) {


    override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
        return initView(position,convertView,parent)
    }

    override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View? {
        return initView(position,convertView,parent)
    }

    fun initView(position: Int,convert: View?,parent: ViewGroup) : View {
        var view = convert
        var prodi = getItem(position)
        var type = prodi?.type
            view = LayoutInflater.from(context).inflate(R.layout.spinner_prodi,parent,false)
            var text = view.findViewById<TextView>(R.id.jurusan)
            text.setText(prodi?.prodi)

        return view!!
     }
}