From f9b08acbafa2f76cd97d5ffd8fc17d54b870def4 Mon Sep 17 00:00:00 2001 From: mosterTeco Date: Mon, 22 Apr 2024 07:45:22 -0600 Subject: [PATCH] Funcionalidad Pantalla Agregar Pantalla con Spinner --- .../com/terratenientes/medicalhealth/AgregarActivity.kt | 9 ++++++++- app/src/main/res/layout/activity_agregar_paciente.xml | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/terratenientes/medicalhealth/AgregarActivity.kt b/app/src/main/java/com/terratenientes/medicalhealth/AgregarActivity.kt index 3a158bc..8648c75 100644 --- a/app/src/main/java/com/terratenientes/medicalhealth/AgregarActivity.kt +++ b/app/src/main/java/com/terratenientes/medicalhealth/AgregarActivity.kt @@ -1,7 +1,9 @@ package com.terratenientes.medicalhealth +import android.R import android.content.Intent import android.os.Bundle +import android.widget.ArrayAdapter import android.widget.Toast import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity @@ -22,6 +24,11 @@ class AgregarActivity : AppCompatActivity() { setContentView(view) db = DoctorDataBaseHelper(this@AgregarActivity) + val opcionesGenero = arrayOf("Masculino", "Femenino", "Otro") + val adapter = ArrayAdapter(this, R.layout.simple_spinner_item, opcionesGenero) + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) + binding.edtxSexo.adapter = adapter + binding.btnConfirmar.setOnClickListener { agregarPaciente() val intent = Intent(this@AgregarActivity, EliminarActivity::class.java) @@ -33,7 +40,7 @@ class AgregarActivity : AppCompatActivity() { val apellidoPaterno = binding.edtxApellidoPat.text.toString() val apellidoMaterno = binding.edtxApellidoMat.text.toString() val edad = binding.edtxEdad.text.toString().toIntOrNull() - val sexo = binding.edtxSexo.text.toString() + val sexo = binding.edtxSexo.selectedItem.toString() // Obtener el valor seleccionado del Spinner val domicilio = binding.edtxDomicilio.text.toString() if (nombre.isNotEmpty() && apellidoPaterno.isNotEmpty() && apellidoMaterno.isNotEmpty() && edad != null && sexo.isNotEmpty() && domicilio.isNotEmpty()) { diff --git a/app/src/main/res/layout/activity_agregar_paciente.xml b/app/src/main/res/layout/activity_agregar_paciente.xml index d880bc1..0899e8d 100644 --- a/app/src/main/res/layout/activity_agregar_paciente.xml +++ b/app/src/main/res/layout/activity_agregar_paciente.xml @@ -48,14 +48,13 @@ android:digits="1234567890" /> - - - \ No newline at end of file + +