Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val spn_sexo= findViewById<Spinner>(R.id.spn_sexo)
- val txt_idade=findViewById<EditText>(R.id.txt_idade)
- val btn_button=findViewById<Button>(R.id.btn_enviar)
- val txt_resultado=findViewById<TextView>(R.id.txt_resultado)
- spn_sexo.adapter= ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item, listOf("masculino","feminino"))
- btn_button.setOnClickListener {
- val sexo=spn_sexo.selectedItem as String
- val idade=txt_idade.text.toString().toInt()
- var resultado=0
- if (sexo=="masculino"){
- resultado=65-idade
- }else{
- resultado=60-idade
- }
- txt_resultado.text="Faltam $resultado anos para você se aposentar."
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement