Main
package [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
[Link](savedInstanceState)
enableEdgeToEdge()
setContentView([Link].activity_main)
val nombre = findViewById<EditText>([Link])
val correo = findViewById<EditText>([Link])
val edad = findViewById<EditText>([Link].editTextText3)
val aseptar =findViewById<Button>([Link])
[Link]{
if(comprobar(nombre,correo,edad)){
val intent= Intent(this,vizual::[Link])
[Link]("nombre", [Link]())
[Link]("correo", [Link]())
[Link]("edad", [Link]())
startActivity(intent)
}
}
fun comprobar(nombre: EditText?, correo: EditText?, edad:
EditText?): Boolean {
val nombreTexto = nombre?.[Link]()
val correoTexto = correo?.[Link]()
val edadTexto = edad?.[Link]()
if ([Link]()) {
if (nombre != null) {
[Link] = "Por favor, ingresa tu nombre"
}
return false
}
if ([Link]()) {
if (correo != null) {
[Link] = "Por favor, ingresa tu correo
electrónico"
}
return false
}
if (!
[Link].EMAIL_ADDRESS.matcher(correoTexto).matches()) {
if (correo != null) {
[Link] = "Por favor, ingresa un correo
electrónico válido"
}
return false
}
if ([Link]()) {
if (edad != null) {
[Link] = "Por favor, ingresa tu edad"
}
return false
}
return true
}
}
xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:gravity="center"
android:text="DATOS PERSONALES"
android:textSize="30sp"
tools:layout_editor_absoluteY="161dp"
tools:layout_editor_absolutex="76dp"/>
<EditText
android:id="@+id/editTextText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text"
android:text=""
android:hint="Nombre"
android:layout_marginTop="140dp"
tools:layout_editor_absolutex="31dp"
tools:layout_editor_absolutey="185dp"
/>
<EditText
android:id="@+id/correoar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress"
android:text=""
android:hint="Email"
android:layout_marginTop="190dp"
tools:layout_editor_absolutex="31dp"
tools:layout_editor_absolutey="185dp"
/>
<EditText
android:id="@+id/editTextText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="240dp"
android:ems="10"
android:inputType="text"
android:text=""
android:hint="Edad"
tools:layout_editor_absolutex="31dp"
tools:layout_editor_absolutey="185dp" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="320dp"
android:drawableLeft="@android:drawable/checkbox_on_background"
android:text="Button"
tools:layout_editor_absolutex="31dp"
tools:layout_editor_absolutey="185dp" />
</FrameLayout>
Visual
package [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
class vizual : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
[Link](savedInstanceState)
enableEdgeToEdge()
setContentView([Link].activity_vizual)
val nombreU = findViewById<TextView>([Link].textView3)
val correoU = findViewById<TextView>([Link].textView4)
val edadU = findViewById<TextView>([Link].textView5)
val regresar = findViewById<Button>([Link].button2)
var data=[Link]
[Link] = data!!.getString("nombre")
[Link] = data!!.getString("correo")
[Link]=data!!.getString("edad")
[Link]{
var intent=Intent(this,MainActivity::[Link])
startActivity(intent)
}
}
}
xml
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".vizual">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DATOS PERSONALES"
android:textSize="30sp"
android:layout_marginTop="50dp"
tools:layout_editor_absoluteX="77dp"
tools:layout_editor_absoluteY="161dp" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_marginTop="120dp"
tools:layout_editor_absoluteX="77dp"
tools:layout_editor_absoluteY="217dp" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_marginTop="30dp"
tools:layout_editor_absoluteX="77dp"
tools:layout_editor_absoluteY="278dp" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_marginTop="30dp"
tools:layout_editor_absoluteX="164dp"
tools:layout_editor_absoluteY="86dp" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_marginTop="60dp"
tools:layout_editor_absoluteX="79dp"
tools:layout_editor_absoluteY="410dp" />
</LinearLayout>
</[Link]>