144
CECYTEM PLANTEL Tecámac Mares Islas Blanca Lidia Grupo: 403 Aplicaciones Móviles Prof.: Domínguez Escalona Rene MANUAL

manual_mares islas blanca lidia_403

Embed Size (px)

Citation preview

Page 1: manual_mares islas blanca lidia_403

CECYTEM PLANTEL

Tecámac

Mares Islas Blanca Lidia

Grupo: 403

Aplicaciones Móviles

Prof.: Domínguez Escalona Rene

MANUAL

Page 2: manual_mares islas blanca lidia_403

INDICE

1.-Hola Mundo

2.-Operaciones

3.-Album

4.-Spinner

5.-RadioButton

6.-ToggleButton

7.-ColorHex

8. - Sonidos Animales

9.-WebView

10.- CheckBox

11.-Menu

12.-ListView

13.-Acelerometro

14.-Giroscopio

15.-VideoView

16.-Acelerometro

17.-Canvas

18.-Gato

19.-Calculadora

20.-….

21.-VideoView

22.-Giroscopio

23.-Notificaciones

24.-….

25.-CheckBox

26.-RadioButton

27.-Progress Bar

28.-Spinner

29.-WebView

30.-TimePicker

31.-DatePicker

Hola Mundo

Lo que vamos a hacer para comenzar es crear nuestro primer proyecto. Hacemos "File / New /

Page 3: manual_mares islas blanca lidia_403

Project…". Nos sale una ventana donde seleccionamos "Java project".

Ahora encontramos una ventana de configuración del proyecto que tenemos que rellenar convenientemente.

1. Asignamos un nombre al proyecto.2. Dejamos marcada "Use default location", para que

use la ruta de nuestro workspace configurado y Eclipse se encargará de hacer un subdirectorio para este nuevo proyecto.

3. JRE puedes dejar la que tienes por defecto en Eclipse.

4. En project layout puedes dejar también la configuración que te sale "create separate folders…"

5. Pulsamos "Finish"

Cuando terminas el proceso en el lado izquierdo, panel de "projects", nos sale el proyecto que acabamos de crear. Es un árbol desplegable en el que si examinas dentro encontrarás:

Page 4: manual_mares islas blanca lidia_403

Carpeta src: es donde está el código fuente de tus clases, todos los .class que irás creando con tu código Java.Carpeta JRE: encuentras toda una serie de .jar, que es una forma de englobar varios archivos de clases. En definitiva, aquí encontrarás todas las clases que dispones en Java para realizar cualquier tipo de tarea.Crear un nuevo código para implementar el "Hola Mundo"Ahora vamos a crear nuestro primer archivo dentro del proyecto para hacer nuestro primer ejemplo en Java. Es bien simple realmente, pero recuerda que Java solo trabaja con programación orientada a objetos (POO), por lo que alguna cosa puede ser poco familiar para ti, si no conoces este paradigma.

1. Botón derecho en el proyecto que acabas de crear2. Seleccionas "New / Class". (Un class es una clase

de POO)3. En el campo "Name" indicas el nombre de tu clase4. Todo lo demás lo puedes dejar como está, más

adelante explicaremos qué otras cosas te aparecen en esta pantalla y el por qué de su existencia

5. Pulsas el Botón "Finish" para acabar

Page 5: manual_mares islas blanca lidia_403

Con esto hemos creado ya nuestro primer archivo y Eclipse nos mostrará el código con el que partimos. Observarás que el archivo ya tiene un código escrito, es la declaración de una clase de Programación Orientada a Objetos (class en inglés).

Todo en Java va dentro de las clases, exceptuando los "import" que van fuera de las llaves de tu "class". De momento no nos tenemos que preocupar más que con el código para crear una salida con el mensaje "Hola Mundo", pero aquí es donde decíamos que Java es un poco doloroso para hacer nuestro primer programa, porque necesitamos varias cosas para que todo esto funcione.

Page 6: manual_mares islas blanca lidia_403

Creo que lo mejor sería ver el código fuente del "Hola Mundo" completo y a partir de ahí explicar lo que nos encontramos.

public class HolaMundo {public static void main(String[] argumentos){System.out.println("Hola mundo");}}Rápidamente, estos son los elementos que te puedes fijar:

"public class" es una declaración de la clase.  "HolaMundo" es el nombre de la clase que estamos

creando. Por convención los nombres de las clases en Java tienen la primera letra en mayúscula. 

"public static void main" es la declaración de un método público y estático llamado "main" que no devuelve valor alguno. De momento olvida todo lo demás y quédate que en Java; cuando quieres ejecutar una clase debes crear este método "main" tal como está. Al ejecutar una clase se pondrá todo en marcha a partir del código que hayas escrito en tu "main". 

"String[] argumentos" son los parámetros que recibe todo método main, que sirven para enviar por consola argumentos para que al ejecutar la clase se personalice el comportamiento. De momento no vamos a hacer nada con esos argumentos, por lo que puedes obviar este código. 

"System.out.println("Hola mundo");" es la línea de código que hace realmente el "Hola mundo". Lo que indica es que estás enviando una salida, en este

Page 7: manual_mares islas blanca lidia_403

caso por pantalla. Es una manera un poco fea o complicada de decir simplemente a Java que muestre algo por pantalla, pero recuerda que todo en Java son clases, por lo que aquí estás accediendo a una jerarquía de clases y al método "println()" que es el encargado de imprimir una línea. A ese método se le envía una cadena, en este caso "Hola mundo" que es aquello que debe mostrar por pantalla.

Ejecutar una clase desde EclipseUna vez que hemos escrito el código de nuestra clase estamos listos para ejecutarla. Lo hacemos dentro del propio IDE eclipse, con el botón "run", que tiene forma de un botón de play, en la barra de menús de arriba del todo.Cuando ejecutas te aparece la salida en una consola, en un panel en la parte de abajo de Eclipse, en el que deberías ver el mensaje de salida de la ejecución de tu primer programa.

Page 8: manual_mares islas blanca lidia_403

Operaciones

Iniciaremos Creando Nuestro Proyecto.

Debes nombrar tu Activity

Te abrira xml java.

Despues Te Vas A Res/Layout/activity

Xml:

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

Page 9: manual_mares islas blanca lidia_403

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#FFCC00" COLOR

android:orientation="vertical" >ORIENTACION

Edit Text Este nos ayudara a Ingresar numeros

<EditText

android:id="@+id/num"

android:layout_width="match_parent"

android:layout_height="50dp"

android:layout_margin="10dp"

android:background="#CC00FF"

android:hint="numero 1"

android:maxLength="10"

android:numeric="decimal"

android:textColor="#00FFCC"

android:textStyle="bold" />

<EditText

android:id="@+id/numd"

android:layout_width="match_parent"

android:layout_height="50dp"

Page 10: manual_mares islas blanca lidia_403

android:layout_margin="10dp"

android:background="#00FFCC "

android:hint="numero 2"

android:maxLength="10"

android:numeric="decimal"

android:textColor="#00FFCC "

android:textStyle="bold" />

<LinearLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal" >

Botones uno de nos ayudara a Calcular y Eliminar.

<Button

android:id="@+id/cal"

android:layout_width="match_parent"

android:layout_height="50dp"

android:layout_margin="10dp"

android:layout_weight="1"

android:background="#00FFCC "

android:text="calcular"

android:textStyle="bold" />

Page 11: manual_mares islas blanca lidia_403

<Button

android:id="@+id/bor"

android:layout_width="match_parent"

android:layout_height="50dp"

android:layout_margin="10dp"

android:layout_weight="1"

android:background="#00FFCC "

android:text="borrar"

android:textStyle="bold" />

</LinearLayout>

TextView imprimiran los resultados de numeros.

<TextView

android:id="@+id/res"

android:layout_width="match_parent"

android:layout_height="102dp"

android:layout_margin="10dp"

android:layout_weight="0.37"

android:background="#00FFCC "

android:text="resultado"

android:textStyle="bold" />

Page 12: manual_mares islas blanca lidia_403

</LinearLayout>

*java

Librerias

package aplicacion.operaciones;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.*;

import android.app.Activity;

import android.view.Menu;

El metodo Onclick En La Clase

public class Operaciones extends Activity implements OnClickListener{

Declaramos variables

EditText edtnumerouno, edtnumerodos;

TextView txtresultado;

Button btncalcular, btnborrar; BOTONES

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_operaciones);

variables enlazadas con XML

Page 13: manual_mares islas blanca lidia_403

edtnumerouno=(EditText) findViewById(R.id.num);

edtnumerodos=(EditText) findViewById(R.id.numd);

txtresultado=(TextView) findViewById(R.id.res);

btncalcular=(Button) findViewById(R.id.cal);

btnborrar=(Button) findViewById(R.id.bor);

btncalcular.setOnClickListener(this);

btnborrar.setOnClickListener(this);

}

Metodo OnClick

public void onClick(View v) {

switch(v.getId()){

case R.id.cal:

String u=edtnumerouno.getText().toString();

String g=edtnumerodos.getText().toString();

if(!u.equals("") && !g.equals("")){

double uno=Double.parseDouble(edtnumerouno.getText().toString());

double dos=Double.parseDouble(edtnumerodos.getText().toString());

if(uno<dos){

Page 14: manual_mares islas blanca lidia_403

txtresultado.setText("la suma es: "+(dos+uno)+"\n resta es: "+(dos-uno)+"\n multiplicacion es:"+(dos*uno)+"\n division es: "+(dos/uno));

break;

}

}

case R.id.bor:

edtnumerouno.setText("");

edtnumerodos.setText("");

txtresultado.setText("");

break;}

}

}

Page 15: manual_mares islas blanca lidia_403

Album

Cambia fondo de pantalla.

RES/LAYOUT/Activity_album

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

ImageView mostrara imagen de pantalla

<ImageView

android:id="@+id/imagen1"

android:layout_width="match_parent"

android:layout_height="200dp"

android:src="@drawable/a" />

HorizontalScrollView Imágenes Forma Horizontal.

<HorizontalScrollView

Page 16: manual_mares islas blanca lidia_403

android:layout_width="match_parent"

android:layout_height="100sp" >

Layout Ordenara

<LinearLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal" >

ImageView seran las Imágenes-imprimir las imagenes.

<ImageView

android:id="@+id/ima1"

android:layout_width="100sp"

android:layout_height="100sp"

android:src="@drawable/c" />

<ImageView

android:id="@+id/ima2"

android:layout_width="100sp"

android:layout_height="100sp"

android:src="@drawable/d" />

<ImageView

android:id="@+id/ima3"

android:layout_width="100sp"

Page 17: manual_mares islas blanca lidia_403

android:layout_height="100sp"

android:src="@drawable/e"

<ImageView

android:id="@+id/ima4"

android:layout_width="100sp"

android:layout_height="100sp"

android:src="@drawable/f"

<ImageView

android:id="@+id/ima5"

android:layout_width="100sp"

android:layout_height="100sp"

android:src="@drawable/g" />

<ImageView

android:id="@+id/ima6"

android:layout_width="100sp"

android:layout_height="100sp"

android:src="@drawable/h"

<ImageView

android:id="@+id/ima7"

android:layout_width="100sp"

android:layout_height="100sp"

android:src="@drawable/i"

Imagen

Page 18: manual_mares islas blanca lidia_403

</LinearLayout>

</HorizontalScrollView>

Boton Cerrar Linear Layout

<Button

android:id="@+id/cambiar"

android:layout_width="match_parent"

android:layout_height="70sp"

android:text="Cambiar wallpaper" />

</LinearLayout>

*java

Librerias

import android.os.Bundle;

import android.app.Activity;

import android.app.WallpaperManager;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.*;

Despues implementaremos el metodo OnClick

public class InterfazActivity extends Activity implements OnClickListener{

Page 19: manual_mares islas blanca lidia_403

Declaramos variables

ImageView image,ima1, ima2, ima3, ima4, ima5, ima6, ima7;

Button btn;

int fondo;

Cuerpo Programa Variables XML-Imágenes.

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.interfaz);

image1=(ImageView) findViewById (R.id.ima1);

image2=(ImageView) findViewById (R.id.ima2);

image3=(ImageView) findViewById (R.id.ima3);

image4=(ImageView) findViewById (R.id.ima4);

image5=(ImageView) findViewById (R.id.ima5);

image6=(ImageView) findViewById (R.id.ima6);

image7=(ImageView) findViewById (R.id.ima7);

btn=(Button) findViewById (R.id.cambiar);

image1.setOnClickListener(this);

image2.setOnClickListener(this);

image3.setOnClickListener(this);

Page 20: manual_mares islas blanca lidia_403

image4.setOnClickListener(this);

image5.setOnClickListener(this);

image6.setOnClickListener(this);

image7.setOnClickListener(this);

}

@Override

El Metodo OnClick Para fondo de pantalla.

public void onClick(View v) {

switch (v.getId()){

case R.id.ima1:

image1.setImageResource(R.drawable.a);

fondo = R.drawable.a;

break;

case R.id.ima2:

image2.setImageResource(R.drawable.b);

fondo = R.drawable.b;

break;

case R.id.ima3:

image3.setImageResource(R.drawable.c);

fondo = R.drawable.c;

break;

Page 21: manual_mares islas blanca lidia_403

case R.id.ima4:

image4.setImageResource(R.drawable.d);

fondo = R.drawable.d;

break;

case R.id.ima5:

image5.setImageResource(R.drawable.e);

fondo = R.drawable.e;

break;

case R.id.ima6:

image6.setImageResource(R.drawable.f);

fondo = R.drawable.f;

break;

case R.id.ima7:

image7.setImageResource(R.drawable.g);

fondo = R.drawable.g;

break;

case R.id.cambiar:

WallpaperManager mywp=WallpaperManager.getInstance(getApplicationContext());

try{

Page 22: manual_mares islas blanca lidia_403

mywp.setResource(fondo);

}catch(Exception e){

e.printStackTrace();

}

Toast.makeText(this, " Nuevo Wallpaper", Toast.LENGTH_LONG).show();

break;

}

Spinner

RES/LAYOUT/ACTIVITY

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

Page 23: manual_mares islas blanca lidia_403

android:layout_height="match_parent"

android:background="#ccc"

android:orientation="vertical"

tools:context=".MainActivity" >

Text View Primera Lista Despegable

<TextView

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="1"

android:gravity="center"

android:text="cual es tu opcion"

android:textColor="#000"

android:textSize="15sp" />

Despues Van Los Spinner

<Spinner

android:id="@+id/sp1"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_margin="10sp"

android:layout_weight="1"

android:textSize="15sp" />

<Spinner

Page 24: manual_mares islas blanca lidia_403

android:id="@+id/sp2"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_margin="10sp"

android:layout_weight="1"

android:textSize="15sp" />

Image View Imprimira Una Imagen Y Se Cierra El Layout

<ImageView

android:id="@+id/image"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_margin="10sp"

android:layout_weight=".7"

android:background="#333" />

</LinearLayout>

*Java

librerias

import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.widget.AdapterView;

Page 25: manual_mares islas blanca lidia_403

import android.widget.AdapterView.OnItemSelectedListener;

import android.widget.ArrayAdapter;

import android.widget.ImageView;

import android.widget.Spinner;

Clase Incrementara METODO ONCLICK

public class MainActivity extends Activity implements OnItemSelectedListener {

Declarar variables opciones de spinner

Spinner sp1, sp2;

ImageView img;

ArrayAdapter<String> a, a1, a2, a3, a4, a5;

int sel2 = 0;

String[] opcMarca = new String[] { "VolksWagen", "Ford", "Nissan", "Honda",

"BMW" };

String[] opcVW = new String[] { "Caribe", "Atlantic", "Golf", "Jetta",

"Bora" };

String[] opcFord = new String[] { "Mustang", "Fusion", "Fiesta", "Lobo",

"Ikon" };

String[] opcNissan = new String[] { "NP300", "Sentra", "Altima", "X-Terra",

Page 26: manual_mares islas blanca lidia_403

"Frontier" };

String[] opcHonda = new String[] { "Civic", "Accord", "CRV", "Odyssey",

"Pilot" };

String[] opcBMW = new String[] { "Sedan", "Coupe", "Roadster", "i3", "i8" }

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

spinner variables xml, java

sp1 = (Spinner) findViewById(R.id.sp1);

sp2 = (Spinner) findViewById(R.id.sp2);

img = (ImageView) findViewById(R.id.image);

sp1.setOnItemSelectedListener(this);

sp2.setOnItemSelectedListener(this);

a = new ArrayAdapter<String>(this,

android.R.layout.simple_spinner_item, opcMarca);

a1 = new ArrayAdapter<String>(this,

Page 27: manual_mares islas blanca lidia_403

android.R.layout.simple_spinner_item, opcVW);

a2 = new ArrayAdapter<String>(this,

android.R.layout.simple_spinner_item, opcFord);

a3 = new ArrayAdapter<String>(this,

android.R.layout.simple_spinner_item, opcNissan);

a4 = new ArrayAdapter<String>(this,

android.R.layout.simple_spinner_item, opcHonda);

a5 = new ArrayAdapter<String>(this,

android.R.layout.simple_spinner_item, opcBMW);

sp1.setAdapter(a);

sp2.setAdapter(a1);

}

@Override

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,

Page 28: manual_mares islas blanca lidia_403

long arg3) {

switch (arg0.getId()) {

case R.id.sp1:

int sel = sp1.getSelectedItemPosition();

switch (sel) {

case 0:

sp2.setAdapter(a1);

sel2 = sp2.getSelectedItemPosition();

switch (sel2) {

case 0:

img.setImageResource(R.drawable.caribe);

break;

case 1:

img.setImageResource(R.drawable.atlantic);

break;

case 2:

img.setImageResource(R.drawable.golf);

break;

case 3:

img.setImageResource(R.drawable.jetta);

Page 29: manual_mares islas blanca lidia_403

break;

case 4:

img.setImageResource(R.drawable.bora);

break;

}

break;

case 1:

sp2.setAdapter(a2);

sel2 = sp2.getSelectedItemPosition();

switch (sel2) {

case 0:

img.setImageResource(R.drawable.mustang);

break;

case 1:

img.setImageResource(R.drawable.fusion);

break;

case 2:

img.setImageResource(R.drawable.fiesta);

break;

case 3:

Page 30: manual_mares islas blanca lidia_403

img.setImageResource(R.drawable.lobo);

break;

case 4:

img.setImageResource(R.drawable.ikon);

break;

}

break;

case 2:

sp2.setAdapter(a3);

sel2 = sp2.getSelectedItemPosition();

switch (sel2) {

case 0:

img.setImageResource(R.drawable.np300);

break;

case 1:

img.setImageResource(R.drawable.sentra);

break;

case 2:

img.setImageResource(R.drawable.altima);

break;

Page 31: manual_mares islas blanca lidia_403

case 3:

img.setImageResource(R.drawable.xterra);

break;

case 4:

img.setImageResource(R.drawable.frontier);

break;

}

break;

case 3:

sp2.setAdapter(a4);

sel2 = sp2.getSelectedItemPosition();

switch (sel2) {

case 0:

img.setImageResource(R.drawable.crv);

break;

case 1:

img.setImageResource(R.drawable.accord);

break;

case 2:

img.setImageResource(R.drawable.crv);

Page 32: manual_mares islas blanca lidia_403

break;

case 3:

img.setImageResource(R.drawable.odysey);

break;

case 4:

img.setImageResource(R.drawable.pilot);

break;

}

break;

case 4:

sp2.setAdapter(a5);

sel2 = sp2.getSelectedItemPosition();

switch (sel2) {

case 0:

img.setImageResource(R.drawable.sedan);

break;

case 1:

img.setImageResource(R.drawable.coupe);

break;

case 2:

Page 33: manual_mares islas blanca lidia_403

img.setImageResource(R.drawable.roadster);

break;

case 3:

img.setImageResource(R.drawable.i3);

break;

case 4:

img.setImageResource(R.drawable.i8);

break;

}

break;

}

break;

}

}

@Override

public void onNothingSelected(AdapterView<?> arg0) {

// TODO Auto-generated method stub

}

Page 34: manual_mares islas blanca lidia_403

}

RadioButton

Funcionalidad radio button opción multiple.

<Relative Layout xmlns:android="http://schemas.android.com/apk/res/androd"

xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"

Page 35: manual_mares islas blanca lidia_403

android:layout_height="match_parent" android:background="@drawable/sa" >

TextView Imprime botones

<TextView

android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:id="@+id/text" android:text="ChoiceText" />

Radio Group Agrupar Radios Button

<RadioGroup android:id="@+id/myRadioGroup" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/text" android:layout_marginTop="42dp" android:background="#abf234" android:checkedButton="@+id/sound" >

<RadioButton android:id="@+id/sound" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Sound" />

<RadioButton android:id="@+id/vibration"

Page 36: manual_mares islas blanca lidia_403

android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Vibration" />

<RadioButton android:id="@+id/silent" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Silent" /> </RadioGroup>

Cerrar RadioGroup agragar Boton

<Button

android:id="@+id/chooseBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_marginLeft="34dp" android:text="Choose" />

Cerrar RelativeLayout

</RelativeLayout>

Page 37: manual_mares islas blanca lidia_403

*javapackage practica.radiobutton;

libreriasimport android.os.Bundle;import android.app.Activity;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.RadioButton;import android.widget.RadioGroup;importandroid.widget.RadioGroup.OnCheckedChangeLner;import android.widget.TextView;import android.widget.Toast;

public class Radiobutton extends Activity {

Declarar Variables private RadioGroup radioGroup;private RadioButton sound, vibration, silent; private Button button;private TextView textView;

@Overrideprotected void onCreate(Bundle

savedInstanceState) {super.onCreate(savedInstanceState);

Page 38: manual_mares islas blanca lidia_403

setContentView(R.layout.activity_radiobutton); Declarar Radio ButtonradioGroup=(RadioGroup)findViewById(R.id.myRadioGroup);

radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

@OverrideCondiciones para guardar cambio.

public void onCheckedChanged(RadioGroup group, int checkedId) {

// find which radio button is selected

if(checkedId == R.id.silent) {

Toast.makeText(getApplicationContext(), "choice: Silent",

Toast.LENGTH_SHORT).show();} else if(checkedId ==

R.id.sound) {

Toast.makeText(getApplicationContext(), "choice: Sound",

Toast.LENGTH_SHORT).show();} else {

Page 39: manual_mares islas blanca lidia_403

Toast.makeText(getApplicationContext(), "choice: Vibration",

Toast.LENGTH_SHORT).show();}

}

});

sound = (RadioButton) findViewById(R.id.sound);

vibration = (RadioButton) findViewById(R.id.vibration);

silent = (RadioButton) findViewById(R.id.silent);

textView = (TextView) findViewById(R.id.text);

button =

(Button)findViewById(R.id.chooseBtn); button.setOnClickListener(new

OnClickListener() {

@Override

Imprimir mensaje

public void onClick(View v) {int selectedId =

radioGroup.getCheckedRadioButtonId();

Page 40: manual_mares islas blanca lidia_403

// find which radioButton is checked by id

if(selectedId == sound.getId()) {

textView.setText("You chose 'Sound' option");

} else if(selectedId == vibration.getId()) {

textView.setText("You chose 'Vibration' option");

} else {textView.setText("You

chose 'Silent' option");}

} });}

}

ToggleButton

Page 41: manual_mares islas blanca lidia_403

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".ToogleButton" >

Linear Layout acomoda toggle button. <LinearLayout android:id="@+id/fondo" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal" android:orientation="horizontal" >agrgar color en toggle button <ToggleButton android:id="@+id/togglebutton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5sp" android:textOn="Rojo On" android:textOff="Rojo Off" android:text="ToggleButton" /> <ToggleButton android:id="@+id/togglebutton2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5sp" android:textOn="Verde On" android:textOff="Verde Off" android:text="ToggleButton" />

Page 42: manual_mares islas blanca lidia_403

<ToggleButton android:id="@+id/togglebutton3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5sp" android:textOn="Azul On" android:textOff="Azul Off" android:text="ToggleButton" />

cerrar linerlayout</LinearLayout></LinearLayout>

Despues Continuaremos Con El Java package nancy.tooglebutton;

Y Declaremos Las Librerias

import android.os.Bundle;import android.widget.CompoundButton;import android.widget.CompoundButton.OnCheckedChangeListener;import android.widget.LinearLayout;import android.widget.ToggleButton;import android.view.Menu;import android.app.Activity;import android.graphics.Color;

Declaracion Metodo OnClickListener.

Page 43: manual_mares islas blanca lidia_403

public class ToogleButton extends Activity implements OnCheckedChangeListener {declaracion de variablesToggleButton r,v,a;LinearLayout cont;String color="",rj="00",vr="00",az="00"; @Override

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_toogle_button); cont=(LinearLayout)findViewById(R.id.fondo); r=(ToggleButton)findViewById(R.id.togglebutton1); v=(ToggleButton)findViewById(R.id.togglebutton2); a=(ToggleButton)findViewById(R.id.togglebutton3);

r.setOnCheckedChangeListener(this); v.setOnCheckedChangeListener(this); a.setOnCheckedChangeListener(this); }

Case para cambiar color

public void onCheckedChanged(CompoundButton v, boolean isChecked){

Page 44: manual_mares islas blanca lidia_403

switch(v.getId()){case R.id.togglebutton1:

if(isChecked){rj="FF";color="#"+rj+vr+az;

cont.setBackgroundColor(Color.parseColor(color));}else{

rj="00";color="#"+rj+vr+az;

cont.setBackgroundColor(Color.parseColor(color));}break;

case R.id.togglebutton2:if(isChecked){

vr="FF";color="#"+rj+vr+az;

cont.setBackgroundColor(Color.parseColor(color));

}else{

vr="00";color="#"+rj+vr+az;

cont.setBackgroundColor(Color.parseColor(color));}break;

case R.id.togglebutton3:

Page 45: manual_mares islas blanca lidia_403

if(isChecked){az="FF";color="#"+rj+vr+az;

cont.setBackgroundColor(Color.parseColor(color));}else {

az="00";color="#"+rj+vr+az;

cont.setBackgroundColor(Color.parseColor(color));}break;

}}

private ToggleButton setOnCheckedChangeListener(ToogleButton toogleButton) {

// TODO Auto-generated method stubreturn null;

}

}

ColorHexa

Page 46: manual_mares islas blanca lidia_403

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >

Linear Layout acomoda TextView <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" >

<TextView android:id="@+id/red" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5sp" android:layout_weight="1" android:fontFamily="Arial" android:gravity="center" android:text="Rojo" android:textSize="25sp" />

<TextView android:id="@+id/vrojo " android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5sp" android:layout_weight="1" android:fontFamily="Arial" android:gravity="center"

Page 47: manual_mares islas blanca lidia_403

android:text="R:" android:textSize="25sp" /> </LinearLayout>

<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" >SeekBar esto sirve para que se muevan los colores <SeekBar android:id="@+id/rojo" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5sp" android:layout_weight="1" android:gravity="center" android:indeterminate="false" android:max="255" android:progress="1" /> </LinearLayout>

<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" >

<TextView android:id="@+id/green" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5sp" android:layout_weight="1" android:fontFamily="Arial"

Page 48: manual_mares islas blanca lidia_403

android:gravity="center" android:text="Verde" android:textSize="25sp" />

<TextView android:id="@+id/vverde" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5sp" android:layout_weight="1" android:fontFamily="Arial" android:gravity="center" android:text="V:" android:textSize="25sp" /> </LinearLayout>Linear layout para acomodar en que pocision <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" >

<SeekBar android:id="@+id/verde" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5sp" android:layout_weight="1" android:gravity="center" android:indeterminate="false" android:max="255" android:progress="1" /> </LinearLayout>Linear Layout acomoda TextView

Page 49: manual_mares islas blanca lidia_403

<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" >

<TextView android:id="@+id/blue" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5sp" android:layout_weight="1" android:fontFamily="Arial" android:gravity="center" android:text="Azul" android:textSize="25sp" />

<TextView android:id="@+id/vazul" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5sp" android:layout_weight="1" android:fontFamily="Arial" android:gravity="center" android:text="A:" android:textSize="25sp" /> </LinearLayout>

<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" >

Page 50: manual_mares islas blanca lidia_403

<SeekBar android:id="@+id/azul" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5sp" android:layout_weight="1" android:gravity="center" android:indeterminate="false" android:max="255" android:progress="1" /> </LinearLayout>

<TextView android:id="@+id/hex" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5sp" android:fontFamily="Arial" android:gravity="center" android:text="Hexadecimal:" android:textSize="25sp" />

<TextView android:id="@+id/color" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10sp" android:layout_weight="1" android:background="#cccccc" android:fontFamily="Arial" android:gravity="center" android:text="Color"

Page 51: manual_mares islas blanca lidia_403

android:textSize="65sp" />

</LinearLayout>

package scary.rgb;

import android.os.Bundle;

import android.widget.*;import android.app.Activity;

public class RGB extends Activity implements SeekBar.OnSeekBarChangeListener {

SeekBar rojo, verde, azul;TextView vrojo, vverde, vazul, hex, color;int r = 0, v = 0, a = 0;

@Overrideprotected void onCreate(Bundle

savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_rgb);rojo = (SeekBar) findViewById(R.id.rojo);verde = (SeekBar)

findViewById(R.id.verde);azul = (SeekBar) findViewById(R.id.azul);hex = (TextView) findViewById(R.id.hex);vrojo = (TextView) findViewById(R.id.vrojo);vverde = (TextView)

findViewById(R.id.vverde);vazul = (TextView) findViewById(R.id.vazul);color = (TextView) findViewById(R.id.color);

Page 52: manual_mares islas blanca lidia_403

rojo.setOnSeekBarChangeListener(this);verde.setOnSeekBarChangeListener(this);azul.setOnSeekBarChangeListener(this);

}

@Overridepublic void onProgressChanged(SeekBar

seekBar, int progress,boolean fromUser) {

switch (seekBar.getId()) {case R.id.rojo:

r = progress;break;

case R.id.verde:v = progress;break;

case R.id.azul:a = progress;break;

}String c = ColorHex(r, v, a);hex.setText("HEX:" + c);

color.setBackgroundColor(android.graphics.Color.rgb(r, v, a));

}

public String ColorHex(int r, int v, int a) {String color = "";color = "#";color += Integer.toHexString(r);

Page 53: manual_mares islas blanca lidia_403

color += Integer.toHexString(v);color += Integer.toHexString(a);return color;

}

@Overridepublic void onStartTrackingTouch(SeekBar

seekBar) {vrojo.setText("R: " + r);vazul.setText("R: " + a);vverde.setText("R: " + v);

}

@Overridepublic void onStopTrackingTouch(SeekBar

seekBar) {vrojo.setText("R: " + r);vazul.setText("R: " + a);vverde.setText("R: " + v);

}

}

Sonidos De Animales.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"

Page 54: manual_mares islas blanca lidia_403

android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ff9966" android:orientation="vertical" tools:context=".Grafic" >

<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal">

<Button android:id="@+id/uno" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:background="@drawable/auto" />

<Button android:id="@+id/dos" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5sp" android:background="@drawable/avion"/> <Button android:id="@+id/tres"

Page 55: manual_mares islas blanca lidia_403

android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5sp" android:background="@drawable/barco"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal">

<Button android:id="@+id/cuatro" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5sp" android:background="@drawable/bomberos"/> <Button android:id="@+id/cinco" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5sp" android:background="@drawable/caballo"/> <Button android:id="@+id/seis"

Page 56: manual_mares islas blanca lidia_403

android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5sp" android:background="@drawable/camion"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal">

<Button android:id="@+id/siete" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5sp" android:background="@drawable/policia"/> <Button android:id="@+id/ocho" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5sp" android:background="@drawable/tren"/>

</LinearLayout>

Page 57: manual_mares islas blanca lidia_403

</LinearLayout>

package scary.sonidos;

import android.media.AudioManager;import android.media.SoundPool;import android.os.Bundle;import android.app.Activity;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;

public class Grafic extends Activity implements OnClickListener {

SoundPool sp;Button btn1, btn2, btn3, btn4, btn5, btn6,

btn7, btn8;int a1, a2, a3, a4, a5, a6, a7, a8;

@Overrideprotected void onCreate(Bundle

savedInstanceState) {super.onCreate(savedInstanceState);

setContentView(R.layout.activity_grafic);btn1 = (Button) findViewById(R.id.uno);btn2 = (Button) findViewById(R.id.dos);btn3 = (Button) findViewById(R.id.tres);

Page 58: manual_mares islas blanca lidia_403

btn4 = (Button) findViewById(R.id.cuatro);

btn5 = (Button) findViewById(R.id.cinco);

btn6 = (Button) findViewById(R.id.seis);btn7 = (Button)

findViewById(R.id.siete);btn8 = (Button)

findViewById(R.id.ocho);btn1.setOnClickListener(this);btn2.setOnClickListener(this);btn3.setOnClickListener(this);btn4.setOnClickListener(this);btn5.setOnClickListener(this);btn6.setOnClickListener(this);btn7.setOnClickListener(this);btn8.setOnClickListener(this);sp = new SoundPool(8,

AudioManager.STREAM_MUSIC, 0);a1 = sp.load(this, R.raw.uno, 1);a2 = sp.load(this, R.raw.dos, 1);a3 = sp.load(this, R.raw.tres, 1);a4 = sp.load(this, R.raw.cuatro, 1);a5 = sp.load(this, R.raw.cinco, 1);a6 = sp.load(this, R.raw.seis, 1);a7 = sp.load(this, R.raw.siete, 1);a8 = sp.load(this, R.raw.ocho, 1);

}

@Overridepublic void onClick(View v) {

Page 59: manual_mares islas blanca lidia_403

switch (v.getId()) {case R.id.uno:

sp.play(a1, 1, 1, 1, 0, 1);break;

case R.id.dos:sp.play(a2, 1, 1, 1, 0, 1);break;

case R.id.tres:sp.play(a3, 1, 1, 1, 0, 1);break;

case R.id.cuatro:sp.play(a4, 1, 1, 1, 0, 1);break;

case R.id.cinco:sp.play(a5, 1, 1, 1, 0, 1);break;

case R.id.seis:sp.play(a6, 1, 1, 1, 0, 1);break;

case R.id.siete:sp.play(a7, 1, 1, 1, 0, 1);break;

case R.id.ocho:sp.play(a8, 1, 1, 1, 0, 1);break;

}

}}

Page 60: manual_mares islas blanca lidia_403

ChekBox

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" >

<TextView android:layout_width="fill_parent" android:layout_height="wrap_content"

Page 61: manual_mares islas blanca lidia_403

android:hint= "REDES SOCIALES" android:textColor="#FFFFFF" android:textSize="50sp" />

<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="10sp" android:hint= "1.¿Cuál es la red social que tiene como icono un pajarito?" android:textColor="#FFFFFF" android:textSize="15sp" />

<CheckBox android:id="@+id/cereala" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="15sp" android:hint= "facebook" android:textSize= "10sp" />

<CheckBox

package aplicacion.check;

import android.app.Activity;

import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.CheckBox;import android.widget.Toast;

Page 62: manual_mares islas blanca lidia_403

public class Check extends Activity implements OnClickListener {

String message = "";private CheckBox a, b, c, d, e, f, g, h, i;

@Overrideprotected void onCreate(Bundle

savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_check);a = (CheckBox) findViewById(R.id.cereala);b = (CheckBox) findViewById(R.id.cerealb);c = (CheckBox) findViewById(R.id.cerealc);d = (CheckBox) findViewById(R.id.cereald);e = (CheckBox) findViewById(R.id.cereale);f = (CheckBox) findViewById(R.id.cerealf);g = (CheckBox) findViewById(R.id.cerealg);h = (CheckBox) findViewById(R.id.cerealh);i = (CheckBox) findViewById(R.id.cereali);a.setOnClickListener(this);b.setOnClickListener(this);c.setOnClickListener(this);d.setOnClickListener(this);e.setOnClickListener(this);f.setOnClickListener(this);g.setOnClickListener(this);h.setOnClickListener(this);i.setOnClickListener(this);

}

Page 63: manual_mares islas blanca lidia_403

@Overridepublic void onClick(View arg0) {

switch (arg0.getId()) {case R.id.cereala:

message = "Tu respuesta es incorrecta";

Toast.makeText(this, message, Toast.LENGTH_SHORT).show();

break;case R.id.cerealb:

message = "Tu respuesta es incorrecta";

Toast.makeText(this, message, Toast.LENGTH_SHORT).show();

break;case R.id.cerealc:

message = "Tu respuesta es correcta";Toast.makeText(this, message,

Toast.LENGTH_SHORT).show();

break;case R.id.cereald:

message = "Tu respuesta es incorrecta";

Toast.makeText(this, message, Toast.LENGTH_SHORT).show();

Page 64: manual_mares islas blanca lidia_403

break;case R.id.cereale:

message = "Tu respuesta es incorrecta";

Toast.makeText(this, message, Toast.LENGTH_SHORT).show();

break;case R.id.cerealf:

message = "Tu respuesta es correcta";Toast.makeText(this, message,

Toast.LENGTH_SHORT).show();

break;case R.id.cerealg:

message = "Tu respuesta es incorrecta";

Toast.makeText(this, message, Toast.LENGTH_SHORT).show();

break;case R.id.cerealh:

message = "Tu respuesta es incorrecta";

Toast.makeText(this, message, Toast.LENGTH_SHORT).show();

break;

Page 65: manual_mares islas blanca lidia_403

case R.id.cereali:

message = "Tu respuesta es correcta";Toast.makeText(this, message,

Toast.LENGTH_SHORT).show();

break;}

}}

Page 66: manual_mares islas blanca lidia_403

WebView

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >

<WebView android:id="@+id/webView" android:layout_width="match_parent" android:layout_height="match_parent" />

</LinearLayout>

package practica.web;

import android.app.Activity;

import android.os.Bundle;import android.webkit.WebSettings;import android.webkit.WebView;import android.webkit.WebViewClient;

public class Web extends Activity {

Page 67: manual_mares islas blanca lidia_403

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_web); WebView myWebView = (WebView) this.findViewById(R.id.webView); WebSettings webSettings = myWebView.getSettings(); webSettings.setJavaScriptEnabled(true); myWebView.setWebViewClient(new WebViewClient()); myWebView.loadUrl("https://www.youtube.com/watch?v=u_0E5Tm5KhU"); }

Page 68: manual_mares islas blanca lidia_403

Menu

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FF00FF" > <TextView android:id="@+id/mainText" android:layout_width="wrap_content" android:layout_height="wrap_content"

Page 69: manual_mares islas blanca lidia_403

android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:background="#00FFFF" android:text= "Hola" />

</RelativeLayout>

package lili.menu;

import android.os.Bundle;import android.app.Activity;import android.content.Intent;import android.view.Menu;import android.view.MenuItem;import android.widget.TextView;import android.widget.Toast;

public class Mennu extends Activity {

@Overrideprotected void onCreate(Bundle

savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_mennu);

}

Page 70: manual_mares islas blanca lidia_403

@Overridepublic boolean onCreateOptionsMenu(Menu

menu) {// Inflate the menu; this adds items to the

action bar if it is present.getMenuInflater().inflate(R.menu.mennu,

menu);return true;

}

@Overridepublic boolean

onOptionsItemSelected(MenuItem item) {super.onOptionsItemSelected(item);String message = "Title:" + item.getTitle()

+ ", id=" + item.getItemId();Toast.makeText(this,message,

Toast.LENGTH_LONG).show();

switch(item.getItemId()){case R.id.mainText:

startActivity(new Intent(this, HelpActivity.class));

break;

case R.id.action_settings:TextView textView

=(TextView)findViewById(R.id.mainText);textView.setText("Cambiaste el

Texto :)");

}return true;

Page 71: manual_mares islas blanca lidia_403

}

}

Page 72: manual_mares islas blanca lidia_403

ListView

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#f03"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal">

<EditText android:id="@+id/elemento" android:layout_width="match_parent" android:layout_height="fill_parent" android:layout_weight="0.3" android:hint= "Agregar Elemento" android:background="#FFFFFF" android:marqueeRepeatLimit="marquee_forever" android:textSize="25sp" android:textColor="#000000" android:textStyle="bold" />

Page 73: manual_mares islas blanca lidia_403

<Button android:id="@+id/agregar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:background="#3f3" android:text= "Enter" /> </LinearLayout> <ListView android:id="@+id/lista" android:layout_width="match_parent" android:layout_height="wrap_content"/>

</LinearLayout>

package com.example.hola;

import java.util.ArrayList;

import android.os.Bundle;import android.app.Activity;import android.view.View;import android.view.View.OnClickListener;import android.widget.*;

public class Listado extends Activity implements OnClickListener {

EditText android;ArrayList<String> elementos;Button androidpeolpe;ListView lista;ArrayAdapter<String>¡phone;

Page 74: manual_mares islas blanca lidia_403

@Overrideprotected void onCreate(Bundle

savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_list_view);lista = (ListView) findViewById(R.id.lista);elemento = (EditText)

findViewById(R.id.android);btn = (Button) findViewById(R.id.agregar);

elementos = new ArrayList<String>();adaptador = new

ArrayAdapter<String>(this,

android.R.layout.simple_list_item_1, elementos);lista.setAdapter(¡phone);btn.setOnClickListener(this);

}

@Overridepublic void onClick(View v) {

if (v.getId() == R.id.agregar) {

elementos.add(android.getText().toString());androidsetText("");¡phone.notifyDataSetChanged();

}

}

}

Page 75: manual_mares islas blanca lidia_403

Acelerometro

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"

Page 76: manual_mares islas blanca lidia_403

android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#000000" > <TextView android:id="@+id/posisionx" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="10dp" android:textColor="#FFFFFF" android:text="X= "/> <TextView android:id="@+id/posisiony" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10dp" android:textColor="#FFFFFF" android:layout_weight="1" android:text="Y= "/> <TextView android:id="@+id/posisionz" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10dp" android:textColor="#FFFFFF" android:text="Z= " android:layout_weight="1"/>

</LinearLayout>

Page 77: manual_mares islas blanca lidia_403

package com.lili.acelerometro;libreriasimport java.util.List;

import android.app.Activity;import android.content.Intent;import android.content.pm.ActivityInfo;import android.hardware.Sensor;import android.hardware.SensorEvent;import android.hardware.SensorEventListener;import android.hardware.SensorManager;import android.os.Bundle;import android.widget.TextView;

public class Acelerometro extends Activity implements SensorEventListener {

TextView x, y, z;int uno, dos, tres;private Sensor acelerometro;

@Overrideprotected void onCreate(Bundle

savedInstanceState) {super.onCreate(savedInstanceState);

setContentView(R.layout.activity_acelerometro);

x = (TextView) findViewById(R.id.posisionx);y = (TextView) findViewById(R.id.posisiony);z = (TextView) findViewById(R.id.posisionz);

Page 78: manual_mares islas blanca lidia_403

this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

}

protected void onResume() {super.onResume();SensorManager sm = (SensorManager)

getSystemService(SENSOR_SERVICE);List<Sensor> sensors =

sm.getSensorList(Sensor.TYPE_ACCELEROMETER);

if (sensors.size() > 0) {sm.registerListener(this,

sensors.get(0),

SensorManager.SENSOR_DELAY_GAME);}

}

protected void onPause() {SensorManager mSensorManager =

(SensorManager) getSystemService(SENSOR_SERVICE);

mSensorManager.unregisterListener(this, acelerometro);

super.onPause();}

protected void onStop() {SensorManager mSensorManager =

(SensorManager) getSystemService(SENSOR_SERVICE);

Page 79: manual_mares islas blanca lidia_403

mSensorManager.unregisterListener(this, acelerometro);

super.onStop();}

@Overridepublic void onSensorChanged(SensorEvent

event) {this.x.setText("X = " +

event.values[SensorManager.DATA_X]);this.y.setText("Y = " +

event.values[SensorManager.DATA_Y]);this.z.setText("Z = " +

event.values[SensorManager.DATA_Z]);

float xx = event.values[SensorManager.DATA_X];

float yy = event.values[SensorManager.DATA_Y];

float zz = event.values[SensorManager.DATA_Z];

if (xx >= 9.6) {Intent edad= new

Intent(Acelerometro.this,edad.class);startActivity(edad);

}if (yy >= 9.6) {

Intent mundo= new Intent(Acelerometro.this,Mundo.class);

startActivity(mundo);}if (zz >= 9.6) {

Page 80: manual_mares islas blanca lidia_403

Intent operaciones= new Intent(Acelerometro.this,operaciones.class);

startActivity(operaciones);}

}

@Overridepublic void onAccuracyChanged(Sensor arg0,

int arg1) {// TODO Auto-generated method stub

}

}

Page 81: manual_mares islas blanca lidia_403

Calculadora

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000" android:orientation="vertical" tools:context=".Calculadors" >

<TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10sp" android:layout_weight="1" android:id="@+id/cifras" android:background="#ffffff" />Linear Layout acomoda TextView

<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" >

<TextView

Page 82: manual_mares islas blanca lidia_403

android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10sp" android:id="@+id/resultado" android:layout_weight= "1" android:background="#ffffff" />

<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" >declarar botón para elimiar <Button android:id="@+id/boruno" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:background="#ff0000" android:text= "DEL" android:onClick="delete" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

<Button android:id="@+id/bortodo" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1"

Page 83: manual_mares islas blanca lidia_403

android:background="#ff0000" android:text= "AC" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" /> </LinearLayout> </LinearLayout>Linear layout para orientar <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" >

<Button android:id="@+id/siete" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight= "1" android:background="#999999" android:text= "7" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

<Button android:id="@+id/ocho" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp"

Page 84: manual_mares islas blanca lidia_403

android:layout_weight="1" android:background="#999999" android:text= "8" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

<Button android:id="@+id/nueve" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:background="#999999" android:text= "9" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

<Button android:id="@+id/div" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:background="#0066ff" android:text= "/" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

Page 85: manual_mares islas blanca lidia_403

</LinearLayout>

<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" >

<Button android:id="@+id/cuatro" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight= "1" android:background="#999999" android:text= "4" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

<Button android:id="@+id/cinco" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:background="#999999" android:text= "5" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

Page 86: manual_mares islas blanca lidia_403

<Button android:id="@+id/seis" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:background="#999999" android:text= "6" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

<Button android:id="@+id/mul" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:background="#0066ff" android:text= "*" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" /> </LinearLayout>

<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" >

Page 87: manual_mares islas blanca lidia_403

<Button android:id="@+id/uno" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight= "1" android:background="#999999" android:text= "1" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

<Button android:id="@+id/dos" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:background="#999999" android:text= "2" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

<Button android:id="@+id/tres" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1"

Page 88: manual_mares islas blanca lidia_403

android:background="#999999" android:text= "3" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

<Button android:id="@+id/res" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:background="#0066ff" android:text= "-" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" /> </LinearLayout>

<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" >

<Button android:id="@+id/punto" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight= "1"

Page 89: manual_mares islas blanca lidia_403

android:background="#999999" android:text= "." android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

<Button android:id="@+id/cero" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:background="#999999" android:text= "0" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

<Button android:id="@+id/igual" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:background="#33cc00" android:text= "=" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" />

Page 90: manual_mares islas blanca lidia_403

<Button android:id="@+id/mas" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:background="#0066ff" android:text= "+" android:textColor="#fff" android:textSize="30sp" android:textStyle="bold" android:typeface="serif" /> </LinearLayout>

</LinearLayout>

package scary.calculadors;

import android.app.Activity;

import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.TextView;import android.widget.Toast;

public class Calculadors extends Activity implements OnClickListener {

Button btn0, btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btnsuma,

btnresta, btnmult, btndiv, btnigual, btndel, btnac, btnpunto;

Page 91: manual_mares islas blanca lidia_403

TextView txtcifras, txtResultado;float num1 = 0, num2 = 0, resultado = 0;int o = 0;boolean p = false, igual = false;

@Overrideprotected void onCreate(Bundle

savedInstanceState) {super.onCreate(savedInstanceState);

setContentView(R.layout.activity_calculadors);txtcifras = (TextView)

findViewById(R.id.cifras);txtResultado = (TextView)

findViewById(R.id.resultado);btn1 = (Button) findViewById(R.id.uno);btn2 = (Button) findViewById(R.id.dos);btn3 = (Button) findViewById(R.id.tres);btn4 = (Button) findViewById(R.id.cuatro);btn5 = (Button) findViewById(R.id.cinco);btn6 = (Button) findViewById(R.id.seis);btn7 = (Button) findViewById(R.id.siete);btn8 = (Button) findViewById(R.id.ocho);btn9 = (Button) findViewById(R.id.nueve);btn0 = (Button) findViewById(R.id.cero);btnpunto = (Button)

findViewById(R.id.punto);btnsuma = (Button) findViewById(R.id.mas);btnresta = (Button) findViewById(R.id.res);btnmult = (Button) findViewById(R.id.mul);btndiv = (Button) findViewById(R.id.div);btndel = (Button)

findViewById(R.id.bortodo);btnac = (Button) findViewById(R.id.boruno);

Page 92: manual_mares islas blanca lidia_403

btnigual = (Button) findViewById(R.id.igual);btn1.setOnClickListener(this);btn2.setOnClickListener(this);btn3.setOnClickListener(this);btn4.setOnClickListener(this);btn5.setOnClickListener(this);btn6.setOnClickListener(this);btn7.setOnClickListener(this);btn8.setOnClickListener(this);btn9.setOnClickListener(this);btn0.setOnClickListener(this);btnpunto.setOnClickListener(this);btnsuma.setOnClickListener(this);btnresta.setOnClickListener(this);btnmult.setOnClickListener(this);btndiv.setOnClickListener(this);btnigual.setOnClickListener(this);btndel.setOnClickListener(this);btnac.setOnClickListener(this);

}

public void deshabilitar() {btnsuma.setEnabled(false);btnresta.setEnabled(false);btnmult.setEnabled(false);btndiv.setEnabled(false);

}

public void habilitar() {btnsuma.setEnabled(true);btnresta.setEnabled(true);btnmult.setEnabled(true);btndiv.setEnabled(true);

Page 93: manual_mares islas blanca lidia_403

}

public boolean validar() {if (txtResultado.getText().equals("")) {

Toast.makeText(this, "Falta introducir Numero ", Toast.LENGTH_SHORT)

.show();return false;

} else {if (o == 0) {

num1 = Float.parseFloat(txtcifras.getText().toString());

} else {num2 =

Float.parseFloat(txtcifras.getText().toString());}return true;

}}

public void borrar() {txtcifras.setText("");txtResultado.setText("");resultado = 0;num1 = 0;num2 = 0;

}

@Overridepublic void onClick(View v) {

switch (v.getId()) {case R.id.mas:

if (validar() == true) {

Page 94: manual_mares islas blanca lidia_403

if (igual == true) {resultado = num1;igual = false;

} else {resultado = 0;

}txtResultado.setText(num1 + "+");txtcifras.setText("");o = 3;p = false;deshabilitar();

}break;

case R.id.res:if (validar() == true) {

if (igual == true) {resultado = num1;igual = false;

} else {resultado = 0;

}txtResultado.setText(num1 + "-");txtcifras.setText("");o = 4;p = false;deshabilitar();

}break;

case R.id.mul:if (validar() == true) {

if (igual == true) {resultado = num1;igual = false;

Page 95: manual_mares islas blanca lidia_403

} else {resultado = 0;

}txtResultado.setText(num1 + "*");txtcifras.setText("");o = 5;p = false;deshabilitar();

}break;

case R.id.div:if (validar() == true) {

if (igual == true) {resultado = num1;igual = false;

} else {resultado = 0;

}txtResultado.setText(num1 + "/");txtcifras.setText("");o = 6;p = false;deshabilitar();

}break;

case R.id.uno:if (igual == true) {

borrar();igual = false;

}txtResultado.append("1");break;

Page 96: manual_mares islas blanca lidia_403

case R.id.dos:if (igual == true) {

borrar();igual = false;

}txtResultado.append("2");break;

case R.id.tres:if (igual == true) {

borrar();igual = false;

}txtResultado.append("3");break;

case R.id.cuatro:if (igual == true) {

borrar();igual = false;

}txtResultado.append("4");break;

case R.id.cinco:if (igual == true) {

borrar();igual = false;

}txtResultado.append("5");break;

case R.id.seis:if (igual == true) {

borrar();igual = false;

}

Page 97: manual_mares islas blanca lidia_403

txtResultado.append("6");break;

case R.id.siete:if (igual == true) {

borrar();igual = false;

}txtResultado.append("7");break;

case R.id.ocho:if (igual == true) {

borrar();igual = false;

}txtResultado.append("8");break;

case R.id.nueve:if (igual == true) {

borrar();igual = false;

}txtResultado.append("9");break;

case R.id.cero:if (igual == true) {

borrar();igual = false;

}txtResultado.append("0");break;

case R.id.punto:if (p == false && igual == false) {

txtcifras.append(".");

Page 98: manual_mares islas blanca lidia_403

p = true;} else {

if (p == false) {if (resultado != 0) {

borrar();}txtcifras.append(".");p = true;igual = false;

}}break;

case R.id.boruno:String cad =

txtcifras.getText().toString();if (!cad.equals("")) {

char[] cadena = cad.toCharArray();String f = "";for (int i = 0; i <= cadena.length -

2; i++) {f = f + cadena[i];

}txtcifras.setText(f);

} else {Toast.makeText(this, "No hay

valor", Toast.LENGTH_SHORT).show();resultado = 0;habilitar();

}break;

case R.id.bortodo:borrar();habilitar();

Page 99: manual_mares islas blanca lidia_403

break;case R.id.igual:

if (validar() == true) {switch (o) {case 3:

resultado break;

case 4:resultado = num1 - num2;break;

case 5:resultado = num1 * num2;break;

case 6:resultado = num1 / num2;break;

}}o = 0;p = false;num1 = resultado;igual = true;habilitar();txtResultado.append("" + num2);txtcifras.setText("" +

redondear(resultado));break;

}}

/*TheScary*///

public float redondear(float numero) {

Page 100: manual_mares islas blanca lidia_403

return (float) Math.rint(numero * 100000) / 100000;

}}

Page 101: manual_mares islas blanca lidia_403

Giroscopio

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#3366ff" android:orientation="vertical" tools:context=".MainActivity" >

<LinearLayout android:layout_width="match_parent" android:layout_height="50sp" android:orientation="horizontal" >

<TextView android:id="@+id/xid" android:layout_width="match_parent" android:layout_height="match_parent"

Page 102: manual_mares islas blanca lidia_403

android:layout_margin="5sp" android:layout_weight="1" android:text= "TextView" />

<TextView android:id="@+id/yid" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:text= "TextView" />

<TextView android:id="@+id/zid" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5sp" android:layout_weight="1" android:text= "TextView" /> </LinearLayout>

</LinearLayout>

package scary.giro;

Page 103: manual_mares islas blanca lidia_403

import java.util.List;

import android.app.Activity;import android.content.pm.ActivityInfo;import android.hardware.Sensor;import android.hardware.SensorEvent;import android.hardware.SensorEventListener;import android.hardware.SensorManager;import android.os.Bundle;import android.widget.TextView;

public class MainActivity extends Activity implements SensorEventListener {

TextView x, y, z;private Sensor mAccelerometr;

@Overrideprotected void onCreate(Bundle

savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main );x = (TextView) findViewById(R.id.xid);y = (TextView) findViewById(R.id.yid);z = (TextView) findViewById(R.id.zid);

this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

}

protected void onResume() {super.onResume();

Page 104: manual_mares islas blanca lidia_403

SensorManager sm=(SensorManager)getSystemService(SENSOR_SERVICE);

List<Sensor> sensors=sm.getSensorList(Sensor.TYPE_ACCELEROMETER);

if(sensors.size()>0){

sm.registerListener(this,sensors.get(0),SensorManager.SENSOR_DELAY_GAME);

}}

protected void onPause() {SensorManager

mSensorManager=(SensorManager)getSystemService(SENSOR_SERVICE);

mSensorManager.unregisterListener(this,mAccelerometr);

super.onPause();}

protected void onStop() {SensorManager

mSensorManager=(SensorManager)getSystemService(SENSOR_SERVICE);

mSensorManager.unregisterListener(this,mAccelerometr);

Page 105: manual_mares islas blanca lidia_403

super.onStop();}

@Overridepublic void onSensorChanged(SensorEvent

event) {this.x.setText("X =

"+event.values[SensorManager.DATA_X]);this.y.setText("Y =

"+event.values[SensorManager.DATA_Y]);this.z.setText("Z =

"+event.values[SensorManager.DATA_Z]);

}

@Overridepublic void onAccuracyChanged(Sensor arg0,

int arg1) {// TODO Auto-generated method stub

}

}

Page 106: manual_mares islas blanca lidia_403