Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. val spn_sexo= findViewById<Spinner>(R.id.spn_sexo)
  2. val txt_idade=findViewById<EditText>(R.id.txt_idade)
  3. val btn_button=findViewById<Button>(R.id.btn_enviar)
  4. val txt_resultado=findViewById<TextView>(R.id.txt_resultado)
  5.  
  6.  
  7. spn_sexo.adapter= ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item, listOf("masculino","feminino"))
  8.  
  9. btn_button.setOnClickListener {
  10. val sexo=spn_sexo.selectedItem as String
  11. val idade=txt_idade.text.toString().toInt()
  12.  
  13. var resultado=0
  14. if (sexo=="masculino"){
  15. resultado=65-idade
  16. }else{
  17. resultado=60-idade
  18. }
  19. txt_resultado.text="Faltam $resultado anos para você se aposentar."
  20.  
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement