Funcionalidad Pantalla Agregar Pantalla con Spinner
This commit is contained in:
parent
61d7116023
commit
f9b08acbaf
|
@ -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()) {
|
||||
|
|
|
@ -48,14 +48,13 @@
|
|||
android:digits="1234567890"
|
||||
/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:text="@string/et_modificar_sexo" />
|
||||
|
||||
<EditText
|
||||
<Spinner
|
||||
android:id="@+id/edtx_sexo"
|
||||
android:layout_width="109dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -129,3 +128,4 @@
|
|||
android:layout_marginEnd="50dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
Loading…
Reference in New Issue