how to work with an item of a spinner

0

I have a spinner and when I'm in "Annual" I want to modify an EditText, how could I do that, this is my code

val tipo_plan = listOf("Anual","Mensual","Individual")
val adapterTipo_plan = ArrayAdapter<String>(this,
        android.R.layout.simple_spinner_dropdown_item, tipo_plan)

val planTipo = findViewById<Spinner>(R.id.PlanTP)
planTipo.setAdapter(adapterTipo_plan)
    
asked by Adrian Pang 28.06.2018 в 18:21
source

1 answer

0

For this you will have to add the event onItemSelectedListener that is executed when an element of Spinner is selected and then verify that the index 0 that corresponds to An introducir el código aquí ual in the array was selected:

planTipo.onItemSelectedListener = object : AdapterView.OnItemSelectedListener{
    override fun onNothingSelected(parent: AdapterView<*>?) { }

    override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
        if(position == 0)
        {
           // se selecciono Anual, edita el input aqui

        }
    }

}
    
answered by 28.06.2018 / 18:33
source