Sunteți pe pagina 1din 31

FACULTAD DE INGENIERIA

ESCUELA DE INFORMTICA Y DE SISTEMAS

TALLER 5.1: REPASO


De acuerdo a lo explicado en clase, desarrollar una aplicacin mvil de Acceso al
Sistema: Registro de Personas con validaciones y envo de parmetros de una
actividad a otra para el sistema operativo Android, en forma ordenada.
- Acceso al Sistema: Registro de Personas
DESCRIPCIN DE LA APLICACIN
La Aplicacin debe de contener 3 Actividades:
1. Actividad Login: Est actividad debe de permitir al usuario colocar su
Nombre de usuario y Contrasea, luego de ello el usuario podr pulsar el botn
Ingresar.
Esta actividad deber de mostrar un mensaje cada vez que el usuario pulse el
botn Ingresar sin haber digitado su nombre de usuario y su contrasea,
siendo los mensajes los que detallo a continuacin:
- Si est vaco el nombre de usuario el mensaje deber de decir: El nombre
de usuario es Requerido.
- Si el password est vaco entonces en mensaje deber de decir: La
Contrasea es requerida.
2. Actividad Opcin: Est actividad se mostrar luego de que el usuario haya
pulsado el botn Ingresar de la actividad anterior, y tendr las siguientes
caractersticas:
- Se mostrar tu nombre completo en el ttulo de la actividad.
- Se mostrar una vista Button con nombre Registrar Personas.
- Se mostrar un Vista Button con nombre Registrar Persona con Listview
- Se mostrar una vista Button con nombre Salir
- Cada vez que se haga clic en la vista Registrar Personas.
3. Actividad Registrar_Personas: Est actividad se mostrar luego de que el
usuario haya pulsado la vista Registrar personas de la actividad anterior, y
tendr las siguientes caractersticas:
- Registro de datos de la persona: Apellido Paterno, Apellido Materno,
Nombres, DNI.
- Una Vista Button Guardar.
- Las vistas Textview deben de tener las validaciones necesarias de digitacin.
- Si el Apellido Paterno est vaco, el mensaje deber de decir: El Apellido
Paterno es Requerido.
- Si el Apellido Materno est vaco, el mensaje deber de decir: El Apellido
Materno es Requerido.
- Si los Nombres est vaco, el mensaje deber de decir: El Nombre es
Requerido.
- Si el DNI est vaco, el mensaje deber de decir: El DNI es Requerido.

Cada vez que se haga clic en la vista Guardar se mostrar un mensaje.

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina 1

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

Luego de mostrar el mensaje se limpiar los datos que se escribieron en los


EditText.

4. Actividad Registrar_Personas_Listview: Est actividad se mostrar luego


de que el usuario haya pulsado la vista Registrar Persona con Listview de la
actividad anterior, y tendr las siguientes caractersticas:
- Registro de datos de la persona: Apellido Paterno, Apellido Materno,
Nombres, DNI.
- Una Vista Button Guardar.
- Las vistas Textview deben de tener las validaciones necesarias de digitacin.
- Si el Apellido Paterno est vaco, el mensaje deber de decir: El Apellido
Paterno es Requerido.
- Si el Apellido Materno est vaco, el mensaje deber de decir: El Apellido
Materno es Requerido.
- Si los Nombres est vaco, el mensaje deber de decir: El Nombre es
Requerido.
- Si el DNI est vaco, el mensaje deber de decir: El DNI es Requerido.
- Cada vez que se haga clic en la vista Guardar se registrar los datos en
una vista ListView.
- Luego de mostrar el mensaje se limpiar los datos que se escribieron en los
EditText.
5. Actividad Salir: Est actividad har que regresemos a la actividad Login.

DATOS DE LA APLICACIN
1. El Nombre de la Aplicacin deber de ser: IIS_DAM_Taller_5.1 (Apellido
Paterno). Ejemplo: IIS_DAM_ Taller _5.1 (Cieza).
2. Subir Archivo Word con la descripcin paso a paso del desarrollo de la
aplicacin.
3. Comprimir la carpeta del proyecto desarrollado con nombre IIS_DAM_ Taller
_5.1 (Apellido Paterno).zip y luego subir al aula virtual de nuestra universidad.

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina 2

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

Antecedente
Requerimiento. Se creara el login de usuario siguiento el manual IIS_DAM_Taller_4.1
Link de descarga: https://drive.google.com/open?
id=0B6mnx1PitT9hR2kyVzRqRTl0VHM

1) agregamos una vista Large Text y le agregamos el texo Usuario

2) agregamos un Plain Text y le asignamos un id (txt_usuario)

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina 3

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

Desarrollo de la Aplicacin
1) Una vez creado el login vamos al archivo Panel.java y selecionamos
renombrarlo

2) El nuevo nombre ser Opcion.class y clic en refactor

3) Renombramos el archivo
activity_panel

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina 4

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

4) El nuevo nombre ser activity_opcion.xml

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina 5

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

5) Abrimos el archivo activity_opcion

6) Agregamos un botn y le asignamos el id = btn_registrar

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina 6

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

7) Agregamos un segundo botn con el id = btn_registrarLV

8) Creamos una nueva clase

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina 7

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

9) Creamos una nueva clase

10) Se creara la clase Registrar.java

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina 8

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

11) creamos una nueva clase

12) la nombramos RegistrarLV

13) se creo la clase RegistrarLV.java

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina 9

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

14) agregamos un nuevo activity

15) lo Nombramos activity_registrar

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

16) Se creara activity_registrar

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

17) agregamos un nuevo activity

18) lo Nombramos activity_registrarlv

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

19) Se creara activity_registrarlv

20) abrimos el diseo del activity_registrar

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

21) agregamos un editText y le asignamos un id = txt_nombres

22) agregamos un editText y le asignamos un id = txt_apePaterno

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

23) agregamos un editText y le asignamos un id = txt_apeMaterno

24) agregamos un editText y le asignamos un id = txt_dni

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

25) agregamos un Button y le asignamos un id = btn_registrar

26) En la clase Registrar.java agregamos el siguiente cdigo

Inicializamos la variable registrar de tipo button donde asignaremos a nuestro


botn registrar

Button registrar = (Button)findViewById(R.id.btn_registrar);


registrar.setOnClickListener(new View.OnClickListener() {}

capturamos los datos de los EditText del formulario

String
String
String
String

nombre = ((EditText)findViewById(R.id.txt_nombres)).getText().toString();
ape_paterno = ((EditText)findViewById(R.id.txt_apePaterno)).getText().toString();
ape_materno = ((EditText)findViewById(R.id.txt_apeMaterno)).getText().toString();
dni = ((EditText)findViewById(R.id.txt_dni)).getText().toString();

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

Agregamos la validacin de campos vacion con la sentencia If Else

if (nombre.length() < 1 || ape_paterno.length() < 1 || ape_materno.length() < 1 || dni.length() < 1)


{
if (nombre.length() < 1){
Toast.makeText(getApplicationContext(),"El nombre es requerido",Toast.LENGTH_SHORT).show();
}
else if(ape_paterno.length() < 1){
Toast.makeText(getApplicationContext(),"El apellido paterno es
requerido",Toast.LENGTH_SHORT).show();
}
else if(ape_materno.length() < 1){
Toast.makeText(getApplicationContext(),"El apellido materno es
requerido",Toast.LENGTH_SHORT).show();
}
else if(dni.length() < 1){
Toast.makeText(getApplicationContext(),"El Dni es requerido",Toast.LENGTH_SHORT).show();
}
}
else{
Toast.makeText(getApplicationContext(),"Apellido Paterno : "+ape_paterno+ '\n' +"Apellido
Materno :"+ape_materno+ '\n' +"Nombres : "+nombre+ '\n' +"Dni : "+dni, Toast.LENGTH_LONG).show();
}

Codigo Completo

public class Registrar extends AppCompatActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registrar);
Button registrar = (Button)findViewById(R.id.btn_registrar);
registrar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String nombre =
((EditText)findViewById(R.id.txt_nombres)).getText().toString();
String ape_paterno =
((EditText)findViewById(R.id.txt_apePaterno)).getText().toString();
String ape_materno =
((EditText)findViewById(R.id.txt_apeMaterno)).getText().toString();
String dni = ((EditText)findViewById(R.id.txt_dni)).getText().toString();
if (nombre.length() < 1 || ape_paterno.length() < 1 ||
ape_materno.length() < 1 || dni.length() < 1){
if (nombre.length() < 1){
Toast.makeText(getApplicationContext(),"El nombre es
requerido",Toast.LENGTH_SHORT).show();
}
else if(ape_paterno.length() < 1){
Toast.makeText(getApplicationContext(),"El apellido paterno es
requerido",Toast.LENGTH_SHORT).show();
}
else if(ape_materno.length() < 1){
Toast.makeText(getApplicationContext(),"El apellido materno es
requerido",Toast.LENGTH_SHORT).show();
}

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

else if(dni.length() < 1){


Toast.makeText(getApplicationContext(),"El Dni es
requerido",Toast.LENGTH_SHORT).show();
}
}
else{
Toast.makeText(getApplicationContext(),"Apellido Paterno :
"+ape_paterno+ '\n' +"Apellido Materno :"+ape_materno+ '\n' +"Nombres : "+nombre+ '\n'
+"Dni : "+dni, Toast.LENGTH_LONG).show();
}
}

});

27) abrimos el diseo del activity_registrarLV

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

28) agregamos un TextEdit y le agregamos un id = txt_nombresLV

29) agregamos un TextEdit y le agregamos un id = txt_apePaternoLV

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

30) agregamos un TextEdit y le agregamos un id = txt_apeMaternoLV

31) agregamos un TextEdit y le agregamos un id = txt_dniLV

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

32) agregamos un button y le asignamos el id = btn_guardarLV

33) agregamos un listView y le asignamos un id = lv_registros

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

34) En la clase RegistroLV.java agregaremos el siguiente cdigo:


public class RegistrarLV extends AppCompatActivity {
ListView Lista;
Button guardar;
ArrayAdapter<String> adaptador;
ArrayList<String> arrayList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registrarlv);
guardar = (Button)findViewById(R.id.btn_guardarLV);
Lista = (ListView) findViewById(R.id.lv_registros);
arrayList = new ArrayList<String>();
adaptador = new
ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_list_item_1,arrayLis
t);
Lista.setAdapter(adaptador);
guardar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String nombre = ((EditText)
findViewById(R.id.txt_nombreLv)).getText().toString();
String ape_paterno = ((EditText)
findViewById(R.id.txt_apePaternoLV)).getText().toString();
String ape_materno = ((EditText)
findViewById(R.id.txt_apeMaternoLV)).getText().toString();
String dni = ((EditText)
findViewById(R.id.txt_dniLV)).getText().toString();
if (nombre.length() < 1 || ape_paterno.length() < 1 ||
ape_materno.length() < 1 || dni.length() < 1) {
if (nombre.length() < 1) {
Toast.makeText(getApplicationContext(), "El nombre es requerido",
Toast.LENGTH_SHORT).show();
} else if (ape_paterno.length() < 1) {
Toast.makeText(getApplicationContext(), "El apellido paterno es
requerido", Toast.LENGTH_SHORT).show();
} else if (ape_materno.length() < 1) {
Toast.makeText(getApplicationContext(), "El apellido materno es
requerido", Toast.LENGTH_SHORT).show();
} else if (dni.length() < 1) {
Toast.makeText(getApplicationContext(), "El Dni es requerido",
Toast.LENGTH_SHORT).show();
}
} else {
arrayList.add(nombre+" "+ape_paterno+" "+ape_materno+" "+dni);
adaptador.notifyDataSetChanged();
}
}
});
}
}

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

35) en el activity_opcion agregamos un botn y le asignamos el id = btn_salir

36) en el activity_opcion agregamos un botn y le asignamos el id = btn_salir

Inicializamos y asignamos la variable salir de tipo button

Button salir = (Button)findViewById(R.id.btn_salir);

Agregamos la funcin dentro del evento onclickListener del botn salir

salir.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent form3 = new Intent(Opcion.this, Login.class);
startActivity(form3);
}
});

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

import
import
import
import
import
import

Codigo Completo

android.content.Intent;
android.os.Bundle;
android.support.v7.app.AppCompatActivity;
android.view.View;
android.widget.Button;
android.widget.TextView;

/**
* Created by Carlos Frank on 28/09/2015.
*/
public class Opcion extends AppCompatActivity{
Bundle b;
String nombre;
TextView mensaje;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_opcion);
mensaje = (TextView) findViewById(R.id.txt_mensaje);
b = getIntent().getExtras();
nombre = b.getString("nombre");
mensaje.setText("Bienvenido "+nombre);
Button registrar = (Button)findViewById(R.id.btn_registrar);
Button registrarLv = (Button)findViewById(R.id.btn_registrarLV);
Button salir = (Button)findViewById(R.id.btn_salir);
registrar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent form1 = new Intent(Opcion.this, Registrar.class);
startActivity(form1);
}
});
registrarLv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent form2 = new Intent(Opcion.this, RegistrarLV.class);
startActivity(form2);
}
});

salir.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent form3 = new Intent(Opcion.this, Login.class);
startActivity(form3);
}
});

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

37) abrimos el archio AndroidManifests.xml y agregamos lo siguiente:

Activity de la clase Registrar.java

<activity
android:name=".Registrar"
android:label="@string/app_name" >
</activity>

Activity de la clase RegistrarLV.java

<activity
android:name=".RegistrarLV"
android:label="@string/app_name" >
</activity>

Codigo Completo

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.fzcode.iis_dam_taller_51henostroza" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Login"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Opcion"
android:label="@string/app_name" >
</activity>
<activity
android:name=".Registrar"
android:label="@string/app_name" >
</activity>
<activity
android:name=".RegistrarLV"
android:label="@string/app_name" >
</activity>
</application>
</manifest>

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

Execution de la Application

Login. Ingresaremos el usuario(frank) y la contrasea(123456), si hay campos


vacios al presionar el botn ingresar nos mostrara un mensaje indicando el
error. Si los campos esta correctos nos enviara al activity Opcion.

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

Opcion. En el activity opcin estn los botones Registrar Persona,Registrar


Persona con Listview y Salir, que nos enviaran a su respectiva vista a excepcin de
salir, el cual sirve para volver al login

Registrar Persona. En el activity Registrar Persona llenaremos los datos del


formulario, y al presionar el botn registrar nos mostrara los datos concatenados en un
mensaje

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

Registrar Persona con ListView. En el activity Registrar Persona llenaremos


los datos del formulario, y al presionar el botn registrar agregara los datos a un listView

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

FACULTAD DE INGENIERIA
ESCUELA DE INFORMTICA Y DE SISTEMAS

Henostroza Ramos Carlos y Huamanchumo Sosa Sheyla

Pgina

S-ar putea să vă placă și