SlideShare una empresa de Scribd logo
1 de 91
Descargar para leer sin conexión
Como crear una aplicación................................................................1
App Hola Mundo………………………………………………………….2
App Tabla Multiplicar…………………………………………………….3
App Cambiar_Wall_Paper………………………………………………4
App Calculadora_Basica.………………………………………………..5
App VideoView………………………………………………………......6
App WebView……………………………………………………………..7
App ListaView……………………………………………………………..8
App TabHost……………………………………………………………….9
App RadioButton…………………………………………………………..10
App CheckBox……………………………………………………………..11
App Spiner………………………………………………………………….12
App GalleryView……………………………………………………………13
App Sonidos………………………………………………………………...14
App Calcular Edad………………………………………………………….15
App Calculadora2…………………………………………………………...16
App Camara………………………………………………………………….17
App Paso_de_Activities……………………………………………………..18
App SignoZodiacal…………………………………………………………...19
App Colores----………………………………………………………………..20
ó
á
ó
ó ó ó
ó
á
ó
á ó
á
ó ó
ó ó
ó
á á
ó
á
ú
ñ ó
ó ó ñ ó
á
ñ
ó
ó
El único método que sobrescribiremos de esta clase será el método OnCreate, llamado
cuando se crea por primera vez la actividad. En este método lo único que encontramos en
principio, además de la llamada a su implementación en la clase padre, es la llamada al
método setContentView(R.layout.main).
Con esta llamada estaremos indicando a Android que debe establecer como interfaz gráfica
de esta actividad la definida en el recurso R.layout.main, que no es más que la que hemos
especificado en el fichero /res/layout/main.xml. Una vez más vemos la utilidad de las
diferentes constantes de recursos creadas automáticamente en la clase R al compilar el
proyecto.
ó
package com.example.holamundo;
import android.os.Bundle; ///librería
import android.app.Activity; ///librería
import android.view.Menu; ///librería
public class MainActivity extends Activity { ///nombre de la clase
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
En este XML se definen los elementos visuales que componen la interfaz de nuestra
pantalla principal y se especifican todas sus propiedades.
android:text. Texto del control. En Android, el texto de un control se puede especificar
directamente, o bien utilizar alguna de las cadenas de texto definidas en los recursos del
proyecto (fichero strings.xml), en cuyo caso indicaremos su identificador precedido del
prefijo “@string/”.
android: layout_height y android: layout_width. Dimensiones del control con respecto
al layout que lo contiene. Esta propiedad tomará normalmente los valores “wrap_content”
para indicar que las dimensiones del control se ajustarán al contenido del mismo, o bien
“fill_parent” para indicar que el ancho o el alto del control se ajustarán al ancho o alto del
layout contenedor respectivamente.
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView ///Este sirve para poner texto en pantalla.
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Hola_Mundo"
/> ///cierre del TextView
</RelativeLayout> ///Cierre del RelativeLayout.
import android.os.Bundle;
import android.app.Activity;
import android.view.View; //librerías que se Usaran
import android.view.View.OnClickListener;
import android.widget.*;
public class MainActivity extends Activity implements OnClickListener {
//se implementara el método OnClickListener.
EditText edtNumeroUno;
El control EditText (caja de edición de texto) es otro componente indispensable de casi toda
aplicación Android. Es uno de los medios que tiene el usuario para introducir datos a la aplicación.
TextView textResultado;
Los TextView (etiquetas de texto) se utilizan como medio de salida, es decir, para mostrar un
determinado texto al usuario.
Button btnCalcular, btnBorrar;
Es el típico botón normal, contiene un texto y puede contener imágenes de tipo icono que puedes
alinear con el texto.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edtNumeroUno = (EditText) findViewById(R.id.num);
textResultado = (TextView) findViewById(R.id.res);
btnCalcular = (Button) findViewById(R.id.cal);
btnBorrar = (Button) findViewById(R.id.bor);
btnCalcular.setOnClickListener(this);
btnBorrar.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.cal:
String res = " ";
int uno =
Integer.parseInt(edtNumeroUno.getText().toString());
for (int i = 1; i <= 10; i++) { //el for lo que hará
es un ciclo de menor o igual a 10 del numero ingresado.
res = res + " " + uno + " x " + i + " = " + (i *
uno) + "n"; //es el resultado que nos marcara por ejemplo:
5x1=5 hasta el número diez.
}
textResultado.setText(res); //Este jala el resultado
para visualizarse en el EditText.
break;
case R.id.bor:
edtNumeroUno.setText("");
textResultado.setText("");
break;
}
}
}
á á
ó á ó
ú
ú á
í
<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="#9933CC" // Con este parámetro definimos el color de fondo.
android:orientation="vertical" >
<EditText
android:id="@+id/num"//esta propiedad es el ID del control, con el que podremos
identificarlo de forma única.
android:layout_width="304dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:layout_weight="0.32"
android:background="#FFFFFF"//Color de fondo
android:hint="Numero "//visualización de indicación.
android:maxLength="100"
android:numeric="decimal"//datos de tipo decimal.
android:textColor="#00CC00"// Con este parámetro definimos el color de texto.
android:textStyle="bold"//estilo del texto />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/cal"//esta propiedad es el ID del control, con el que
podremos identificarlo de forma única.
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:text="Calcular"
android:textColor="#00CC00"// Con este parámetro definimos el color de
texto.
android:textStyle="bold"//estilo del texto />
<Button
android:id="@+id/bor"//esta propiedad es el ID del control, con el que
podremos identificarlo de forma única.
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:text="Borrar"
android:textColor="#00CC00"// Con este parámetro definimos el color de
texto.
android:textStyle="bold" //estilo del texto />
</LinearLayout>
<EditText
android:id="@+id/res"//esta propiedad es el ID del control, con el que podremos
identificarlo de forma única.
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_margin="10dp"
android:layout_weight="3.46"
android:background="#FFFFFF"//color de fondo
android:hint="Resultado"//visualización de indicación.
android:numeric="decimal"//datos de tipo decimal.
android:textColor="#00CC00" //Con este parámetro definimos el color de texto.
android:textStyle="bold" />
</LinearLayout>
La propiedad más interesante es android:src, que permite indicar la imagen a mostrar. Nuevamente,
lo normal será indicar como origen de la imagen el identificador de un recurso de nuestra
carpeta /res/drawable, por ejemplo android:src=”@drawable/unaimagen”. Además de esta
propiedad, existen algunas otras útiles en algunas ocasiones como las destinadas a establecer el
tamaño máximo que puede ocupar la imagen, android:maxWidth y android:maxHeight.
<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" >
<ImageView
android:id="@+id/image"//esta propiedad es el ID del control, con el que
podremos identificarlo de forma única.
android:layout_width="match_parent"
android:layout_height="200sp"
android:src="@drawable/a"//carpeta donde se encuentra la
imagen./>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="100sp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/image1"//esta propiedad es el ID del control, con el
que podremos identificarlo de forma única.
android:layout_width="100sp"
android:layout_height="100sp"
android:src="@drawable/a""//carpeta donde se encuentra la
imagen. />
<ImageView
android:id="@+id/image2"//esta propiedad es el ID del control, con el
que podremos identificarlo de forma única.
android:layout_width="100sp"
android:layout_height="100sp"
android:src="@drawable/b""//carpeta donde se encuentra la
imagen. />
<ImageView
android:id="@+id/image3""//esta propiedad es el ID del control, con
el que podremos identificarlo de forma única.
android:layout_width="100sp"
android:layout_height="100sp"
android:src="@drawable/c"//carpeta donde se encuentra la
imagen. />
</LinearLayout>
</HorizontalScrollView>
<Button
android:id="@+id/Cambiar"//esta propiedad es el ID del control, con el que
podremos identificarlo de forma única.
android:layout_width="match_parent"
android:layout_height="70sp"
android:text="Cambiar Fondo" />
</LinearLayout>
import android.app.Activity;
import android.app.WallpaperManager;
import android.os.Bundle;
import android.view.View; //Librerías que se usaran
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
ImageView image, image2, image3, image4, image5;
;
//El control ImageView permite mostrar imágenes en la aplicación.
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image = (ImageView) findViewById(R.id.image);
image2 = (ImageView) findViewById(R.id.image2);
image3 = (ImageView) findViewById(R.id.image3);
image4 = (ImageView) findViewById(R.id.image4);
image5 = (ImageView) findViewById(R.id.image5);
btn = (Button) findViewById(R.id.Cambiar);
image.setOnClickListener(this);
image2.setOnClickListener(this);
image3.setOnClickListener(this);
btn.setOnClickListener(this);
}
Se crea un switch con tres casos dependiendo cuantas imágenes tengas el
cual jalaran la imagen de la carpeta drawable.
public void onClick(View v) {
switch (v.getId()) {
case R.id.image:
image.setImageResource(R.drawable.a);
fondo = R.drawable.a;
break;
case R.id.image2:
image.setImageResource(R.drawable.b);
fondo = R.drawable.b;
break;
case R.id.image3:
image.setImageResource(R.drawable.c);
fondo = R.drawable.c;
break;
;
case R.id.Cambiar:
WallpaperManager mywp = WallpaperManager
.getInstance(getApplicationContext());
try {
mywp.setResource(fondo);
} catch (Exception e) {
e.printStackTrace();
//realiza la función de cambiar el Wall_paper.
}
Toast.makeText(this, "Se ha cambiado el Wallpaper",
Toast.LENGTH_LONG).show();
break;
//lo que realiza es mostrar un pequeño cuadro de texto con la
indicación que se le ordene.
}
}
}
á
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#9933CC" //color de fondo.
android:orientation="vertical" >
<EditText
android:id="@+id/num""//esta propiedad es el ID del control, con el que
podremos identificarlo de forma única.
android:layout_width="304dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:layout_weight="0.32"
android:background="#FFFFFF"//color de fondo
android:hint="Numero 1"//visualización de indicación.
android:maxLength="10"
android:numeric="decimal"//datos de tipo decimal.
android:textColor="#00CC00"// Con este parámetro definimos el color de texto.
android:textStyle="bold"/>//estilo del texto
<EditText
android:id="@+id/numd"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="#FFFFFF"
android:hint="Numero 2"
android:maxLength="10"
android:numeric="decimal"
android:textColor="#00CC00"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/cal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:text="Calcular"
android:textColor="#00CC00"
android:textStyle="bold" />
<Button
android:id="@+id/bor"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:text="Borrar"
android:textColor="#00CC00"
android:textStyle="bold" />
</LinearLayout>
<EditText
android:id="@+id/res"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_margin="10dp"
android:background="#FFFFFF"
android:hint="Resultado"
android:maxLength="300"
android:numeric="decimal"
android:textColor="#00CC00"
android:textStyle="bold" />
</LinearLayout>
import android.os.Bundle;
import android.app.Activity;
import android.view.View; //Librerías que se Usaran
import android.view.View.OnClickListener;
import android.widget.*;
public class MainActivity extends Activity implements OnClickListener {
//se implementara el método OnClickListener.
EditText edtNumeroUn, edtNumeroDos;
El control EditText (caja de edición de texto) es otro componente indispensable de casi toda
aplicación Android. Es uno de los medios que tiene el usuario para introducir datos a la aplicación.
TextView textResultado;
Los TextView (etiquetas de texto) se utilizan como medio de salida, es decir, para mostrar un
determinado texto al usuario.
Button btnCalcular, btnBorrar;
Es el típico botón normal, contiene un texto y puede contener imágenes de tipo icono que puedes
alinear con el texto.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edtNumeroUno = (EditText) findViewById(R.id.num);
edtNumeroDos = (EditText) findViewById(R.id.numd);
extResultado = (TextView) findViewById(R.id.res);
btnCalcular = (Button) findViewById(R.id.cal);
btnBorrar = (Button) findViewById(R.id.bor);
btnCalcular.setOnClickListener(this);
btnBorrar.setOnClickListener(this);
}
}
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());
extResultado.setText("La suma es: " + (uno + dos)
+ " n La resta es: " + (uno - dos)
+ " n La multiplicacion es: " + (uno * dos)
+ " n La division es: " + (uno / dos));
//operaciones
} else {
extResultado.setText("valores incorrectos");
//si los valores introducidos no son correctos
}
break;
case R.id.bor:
edtNumeroUno.setText("");
edtNumeroDos.setText("");
extResultado.setText("");
break; //en este caso (borrar) se eliminaran
los datos que anteriormente se colocaron.
}
}
}
<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" >
<VideoView
android:id="@+id/amarillo"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</VideoView>
</RelativeLayout>
import android.os.Bundle;
import android.app.Activity;
import android.net.Uri; //librerías que se usaran
import android.widget.VideoView;
import android.widget.MediaController;
public class MainActivity extends Activity {
//no contiene ningún método implementado.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView video = (VideoView) findViewById(R.id.amarillo);
// Este se enlaza con nuestro identificador de nuestro XML.
Uri path = Uri.parse("android.resource://shinoda.video/" +
R.raw.video);
//se extrae la url donde se encuentra nuestro video
video.setVideoURI(path);
video.setMediaController(new MediaController(this));
//controles de video
video.start(); //inicialización
video.requestFocus();
}
}
Para aguardar nuestro video se crea una carpeta llamada raw donde va a
contener el video en la carpeta res.
<?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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/elemento"""//esta propiedad es el ID del control, con el
que podremos identificarlo de forma única.
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="0.3"
android:contentDescription="agregarDescElemneto"
android:hint="Agregar"//visualización de indicación.
android:marqueeRepeatLimit="marquee_forever"
android:textColor="#ff3366" //color de texto
android:textSize="25sp" //tamaño texto
android:textStyle="bold" > //estilo del texto
</EditText>
<Button
android:id="@+id/agregar"// esta propiedad es el ID del control, con el que
podremos identificarlo de forma única.
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/enter"//boton imagen>
</Button>
</LinearLayout>
<ListView
android:id="@+id/lista"// esta propiedad es el ID del control, con el que
podremos identificarlo de forma única.
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
package shinoda.listaview;
import java.util.ArrayList;
import android.os.Bundle; //librerías que se usaran
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;
public class Lista extends Activity implements OnClickListener {
EditText elemento;
Button btn; //se declaran las variables
ListView lista;
ArrayList<String> elementos;
ArrayAdapter<String> adaptador;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lista);
lista = (ListView) findViewById(R.id.lista);
elemento = (EditText) findViewById(R.id.elemento);
btn = (Button) findViewById(R.id.agregar);
elementos = new ArrayList<String>(); //se crea un arreglo de
elementos es un arreglo de cadenas
adaptador = new ArrayAdapter(this, //este nos sirve para
hacer las converciones
android.R.layout.simple_list_item_1,elementos);
lista.setAdapter(adaptador);
btn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.agregar) {
elementos.add(elemento.getText().toString());
elemento.setText(""); //agregan los elementos y se agrea lo
escrito en el EditText
adaptador.notifyDataSetChanged();//verifica el resultado en
la lista
}
}
}
<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:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Tabhost" >
<TabHost
android:id="@+id/th"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="108dp" >
<Button
android:id="@+id/cancion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/uno"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/dos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/uno"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:id="@+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/tres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/uno" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>
package shinoda.apss;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View.OnClickListener;
import android.view.View; //librerías que se usaraan
import android.widget.Button;
import android.widget.TabHost;
import android.media.AudioManager;
import android.media.SoundPool;
import android.widget.TabHost.TabSpec;
public class Tabhost extends Activity implements OnClickListener {
TabHost th;
SoundPool sp; //se declaran las variables
Button b1t;
int a;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tabhost);
th = (TabHost) findViewById(R.id.th);
b1t = (Button) findViewById(R.id.cancion);
b1t.setOnClickListener(this);
th.setup();
TabSpec ts1 = th.newTabSpec("tab1");
ts1.setIndicator("Uno"); //nombre del tab
ts1.setContent(R.id.tab1);
th.addTab(ts1);
th.setup();
TabSpec ts2 = th.newTabSpec("tab2");
ts2.setIndicator("Dos"); //nombre del tab
ts2.setContent(R.id.tab2);
th.addTab(ts2);
th.setup();
TabSpec ts3 = th.newTabSpec("tab3");
ts3.setIndicator("Tres"); //nmbre del tab
ts3.setContent(R.id.tab3);
th.addTab(ts3);
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="vertical" >
<TextView
android:id="@+id/preg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Como Suenan Algunas Bandas"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />
<RadioGroup //grupo de opciones donde una, y sólo una, de
ellas debe estar marcada obligatoriamente
android1:id="@+id/radio"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content" >
<RadioButton //un grupo de botones RadioButton se define mediante
un elemento RadioGroup
android1:id="@+id/in"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android:textColor="#ffffff"
android1:checked="true"
android1:text="METALLICA" />
<RadioButton
android1:id="@+id/bar"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android:textColor="#FFFFFF"
android1:checked="true"
android1:text="lINKIN PARK" />
<RadioButton
android1:id="@+id/mad"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android:textColor="#FFFFFF"
android1:text="IRON MAIDEN" />
<RadioButton
android1:id="@+id/bor"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android:textColor="#FFFFFF"
android1:text="AC/DC" />
<RadioButton
android1:id="@+id/pol"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android:textColor="#FFFFFF"
android1:text="JUDAS PRIEST" />
<RadioButton
android1:id="@+id/afri"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android:textColor="#FFFFFF"
android1:text="BLACK SABBATH" />
<RadioButton
android1:id="@+id/no"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android:textColor="#FFFFFF"
android1:text="GUNS N&apos; ROSES" />
<RadioButton
android1:id="@+id/ru"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android:textColor="#FFFFFF"
android1:text="LED ZEPPELIN" />
<RadioButton
android1:id="@+id/is"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android:textColor="#FFFFFF"
android1:text="MEGADETH" />
<RadioButton
android1:id="@+id/por"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android:textColor="#FFFFFF"
android1:text="NIRVANA" />
</RadioGroup>
<Button
android1:id="@+id/ok"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android:textColor="#FFFFFF"
android1:text="select" />
</LinearLayout>
package shinoda.rocka;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RadioGroup;
import android.widget.Toast;
public class Bandas extends Activity implements OnClickListener {
View boton;
RadioGroup rg;
int Ok;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bandas);
rg = (RadioGroup) findViewById(R.id.radio);
boton = (View) findViewById(R.id.ok);
boton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Ok = rg.getCheckedRadioButtonId();
switch (Ok) {
case R.id.in:
Toast.makeText(this, "James Hetfield", Toast.LENGTH_SHORT).show();
break; //se definen los distindos casos para que al
momento de oprimir un radio nos aparesca un mensaje distinto
case R.id.bar:
Toast.makeText(this, "Mike Shinoda", Toast.LENGTH_SHORT).show();
break;
case R.id.mad:
Toast.makeText(this, "Bruce Dickinson", Toast.LENGTH_SHORT).show();
break;
case R.id.bor:
Toast.makeText(this, "Brian Johnson", Toast.LENGTH_SHORT).show();
break;
case R.id.pol:
Toast.makeText(this, "Rob Halford", Toast.LENGTH_SHORT).show();
//mensaje que se visualizara
break;
case R.id.afri:
Toast.makeText(this, "Ozzy Osbourne", Toast.LENGTH_SHORT).show();
break;
case R.id.no:
Toast.makeText(this, "Axel Rose", Toast.LENGTH_SHORT).show();
break;
case R.id.ru:
Toast.makeText(this, "Robert Plant", Toast.LENGTH_SHORT).show();
break;
case R.id.is:
Toast.makeText(this, "Dave Mustaine", Toast.LENGTH_SHORT).show();
break;
case R.id.por:
Toast.makeText(this, "Kurt Cobain", Toast.LENGTH_SHORT).show();
break;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<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="#99FFCC"
android:orientation="vertical"
tools:context=".Checkbox" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="AereoBetSel"
android:textColor="#000000"
android:textSize="30sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="72dp"
android:layout_marginLeft="15sp"
android:hint="-Seleccione el destino al que viajara."
android:textColor="#0099FF"
android:textSize="25sp" />
<CheckBox // Un control checkbox se suele utilizar para marcar o
desmarcar
android:id="@+id/a" //esta propiedad es el ID del control, con el que podremos
identificarlo de forma única.
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:layout_marginTop="30sp"
android:hint="Los Angeles"
android:textSize="20sp" />
<CheckBox
android:id="@+id/b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:hint="Argentina"
android:textSize="20sp" />
<CheckBox
android:id="@+id/c"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:hint="Estados Unidos"
android:textSize="20sp" />
<CheckBox
android:id="@+id/d"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:hint="Canada"
android:textSize="20sp" />
<CheckBox
android:id="@+id/e"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:hint="Russia"
android:textSize="20sp" />
<CheckBox
android:id="@+id/f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:hint="Alemania"
android:textSize="20sp" />
</LinearLayout>
package shinoda.aereolinea;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.Toast;
public class Box extends Activity implements OnClickListener {
String message = "";
private CheckBox a, b, c, d, e, f;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_box);
a = (CheckBox) findViewById(R.id.a);
b = (CheckBox) findViewById(R.id.b);
c = (CheckBox) findViewById(R.id.c);
d = (CheckBox) findViewById(R.id.d);
e = (CheckBox) findViewById(R.id.e);
f = (CheckBox) findViewById(R.id.f);
a.setOnClickListener(this);
b.setOnClickListener(this);
c.setOnClickListener(this);
d.setOnClickListener(this);
e.setOnClickListener(this);
f.setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
switch (arg0.getId()) {
case R.id.a:
message = "Avion num:4" + " n Vuelo:455";//mensaje que
visualizara al presionar un CheckBox
Toast.makeText(this, message,
Toast.LENGTH_SHORT).show();
break;
case R.id.b:
message = "Avion num:2" + " n Vuelo:789";
Toast.makeText(this, message,
Toast.LENGTH_SHORT).show();
break;
case R.id.c:
message = "Avion num:5" + " n Vuelo:345";
Toast.makeText(this, message,
Toast.LENGTH_SHORT).show();
break;
case R.id.d:
message = "Avion num:7" + " n Vuelo:215";
Toast.makeText(this, message,
Toast.LENGTH_SHORT).show();
break;
case R.id.e:
message = "Avion num:6" + " n Vuelo:405";
Toast.makeText(this, message,
Toast.LENGTH_SHORT).show();
break;
case R.id.f:
message = "Avion num:8" + " n Vuelo:145";
Toast.makeText(this, message,
Toast.LENGTH_SHORT).show();
break;
}
}
}
<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="@drawable/b"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Elige Una Banda"
android:textColor="#ff3333"
android:textSize="25dp"
android:textStyle="bold" />
<Spinner // el usuario selecciona la lista, se muestra una especie de
lista emergente al usuario con todas las opciones disponibles y al
seleccionarse una de ellas ésta queda fijada en el control.
android:id="@+id/banda"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#ff3333" />
<Spinner
android:id="@+id/integrante"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#ff3333" />
</LinearLayout>
package shinoda.spin;
import android.os.Bundle;
import android.app.Activity;
import android.view.View; //librerías que se Usan
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class Spin extends Activity implements OnItemSelectedListener {
Spinner banda, integrante;
ArrayAdapter<String> aaBanda, aaBanda1, aaBanda2, aaBanda3,
aaBanda4,aaBanda5, Clear;// Es el más sencillo de todos los adaptadores,
y provee de datos a un control de selección a partir de un array de
objetos de cualquier tipo en este caso String.
String[] opcBanda = new String[] { "Metallica", "Rolling Stones",
"The Beatles", "Linkin Park", "Iron Maiden" };
String[] opcBanda1 = new String[] { "James Hetfield", "Kirk
Hammet",
"Lars Ulirich", "Robert Trijillo" };
//cada uno de estos es un arrelo es cual tiene guardado lo elementos
escritos
String[] opcBanda2 = new String[] { "Mick Jagger ", "Keith
Richards",
"Ron Wood", "Charlie Watts" };
String[] opcBanda3 = new String[] { "Paul MacCarthey", "John
Lennon",
"Ringo Starr", "George Harrison" };
String[] opcBanda4 = new String[] { "Mike Shinoda ", "Chester
Bennington ",
"Brad Delson ", "Pohenix", "Mr Hahn" };
String[] opcBanda5 = new String[] { "Bruce Dickinson", "Steve
Harris ",
"Nicko McBrain ", "Adrian Smith" };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_spin);
banda = (Spinner) findViewById(R.id.banda);
integrante = (Spinner) findViewById(R.id.integrante);
banda.setOnItemSelectedListener(this);
integrante.setOnItemSelectedListener(this);
aaBanda = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, opcBanda);
aaBanda1 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, opcBanda1);
aaBanda2 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, opcBanda2);
aaBanda3 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, opcBanda3);
aaBanda4 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, opcBanda4);
aaBanda5 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, opcBanda5);
banda.setAdapter(aaBanda);
}
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int
arg2,
long arg3) {
switch (arg0.getId()) {
case R.id.banda:
int seleccionado = banda.getSelectedItemPosition();
if (seleccionado == 0) {
integrante.setAdapter(aaBanda1);
}
if (seleccionado == 1) {
integrante.setAdapter(aaBanda2);
}
if (seleccionado == 2) {
integrante.setAdapter(aaBanda3);
}
if (seleccionado == 3) {
integrante.setAdapter(aaBanda4);
}
if (seleccionado == 4) {
integrante.setAdapter(aaBanda5);
}
break;
//se declaran los if junto con un switch para que este nos muestres los
elementos del primer spiner.
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
<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="${relativePackage}.${activityClass}" >
<Gallery
android:id="@+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/image1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="5dp"
android:src="@drawable/uno" >
</ImageView>
</LinearLayout>
package shinoda.fotos;
import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.Toast;
@SuppressWarnings("deprecation")
public class Fotos extends Activity {
Integer[] imageIDs = { R.drawable.uno, R.drawable.dos,
R.drawable.tres,
R.drawable.cuatro, R.drawable.cinco, R.drawable.seis };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fotos);
Gallery gallery = (Gallery) findViewById(R.id.gallery1);
gallery.setAdapter(new ImageAdapter(this));
gallery.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Toast.makeText(getBaseContext(),
"Dragon " + (position + 1) + "
seleccionada",
Toast.LENGTH_SHORT).show();
ImageView imageView = (ImageView)
findViewById(R.id.image1);
imageView.setImageResource(imageIDs[position]);
}
});
}
public class ImageAdapter extends BaseAdapter {
private Context context;
private int itemBackground;
public ImageAdapter(Context c) {
context = c;
TypedArray a =
obtainStyledAttributes(R.styleable.MyGallery);
itemBackground = a.getResourceId(
R.styleable.MyGallery_android_galleryItemBackground, 0);
a.recycle(); //estilo de las imagenes
}
public int getCount() {
return imageIDs.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup
parent) {
ImageView imageView = new ImageView(context);
imageView.setImageResource(imageIDs[position]);
imageView.setLayoutParams(new Gallery.LayoutParams(100,
100));
imageView.setBackgroundResource(itemBackground);
return imageView;
}
}
}
<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="#FF5467"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:id="@+id/gato1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/gato" /> //imagen la cual están
guardadas en la carpeta drawable-mdpi.
<Button
android:id="@+id/perro1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/perro" />
<Button
android:id="@+id/burro1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/burro" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:id="@+id/pajaro1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/pajaro"
<Button
android:id="@+id/pardo1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/pardo" />
<Button
android:id="@+id/obeja1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/obeja" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:id="@+id/vaca1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/vaca" />
<Button
android:id="@+id/pato1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/pato" />
<Button
android:id="@+id/puerco1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/puerco" />
</LinearLayout>
</LinearLayout>
á
package com.example.sound_animals;
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 Sounds extends Activity implements OnClickListener {
SoundPool sp;
Button b1t, b2t, b3t, b4t, b5t, b6t, b7t, b8t, b9t;
int a, b, c, d, e, f, g, h, i;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sounds);
b1t = (Button) findViewById(R.id.gato1);
b1t.setOnClickListener(this);
b2t = (Button) findViewById(R.id.perro1);
b2t.setOnClickListener(this);
b3t = (Button) findViewById(R.id.burro1);
b3t.setOnClickListener(this);
b4t = (Button) findViewById(R.id.pajaro1);
b4t.setOnClickListener(this);
b5t = (Button) findViewById(R.id.pardo1);
b5t.setOnClickListener(this);
b6t = (Button) findViewById(R.id.obeja1);
b6t.setOnClickListener(this);
b7t = (Button) findViewById(R.id.vaca1);
b7t.setOnClickListener(this);
b8t = (Button) findViewById(R.id.pato1);
b8t.setOnClickListener(this);
b9t = (Button) findViewById(R.id.puerco1);
b9t.setOnClickListener(this);
sp = new SoundPool(8, AudioManager.STREAM_MUSIC, 0);
a = sp.load(this, R.raw.gato, 1);
b = sp.load(this, R.raw.burro, 1);
c = sp.load(this, R.raw.pardo, 1);
d = sp.load(this, R.raw.cerdaco, 1);
e = sp.load(this, R.raw.pato, 1);
f = sp.load(this, R.raw.twitter, 1);
g = sp.load(this, R.raw.cow, 1);
h = sp.load(this, R.raw.obeja, 1);
i = sp.load(this, R.raw.perro, 1);
}
@Override
public void onClick(View v) {
//se declara un switch con los distintos casos el cual dependiendo el
caso al presionar un botón sonara el sonido requerido.
switch (v.getId()) {
case R.id.gato1:
sp.play(a, 1, 1, 1, 0, 1);
break;
case R.id.perro1:
sp.play(b, 1, 1, 1, 0, 1);
break;
case R.id.pato1:
sp.play(c, 1, 1, 1, 0, 1);
break;
case R.id.pajaro1:
sp.play(d, 1, 1, 1, 0, 1);
break;
case R.id.puerco1:
sp.play(e, 1, 1, 1, 0, 1);
break;
case R.id.obeja1:
sp.play(f, 1, 1, 1, 0, 1);
break;
case R.id.pardo1:
sp.play(g, 1, 1, 1, 0, 1);
break;
case R.id.vaca1:
sp.play(h, 1, 1, 1, 0, 1);
break;
case R.id.burro1:
sp.play(i, 1, 1, 1, 0, 1);
break;
}
}
}
<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" >
<EditText
android:id="@+id/anio"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="#FFFFFF"
android:hint="AÑO"
android:maxLength="10"
android:numeric="decimal"
android:textColor="#00CC00"
android:textStyle="bold" />
<EditText
android:id="@+id/mes"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="#FFFFFF"
android:hint="MES"
android:maxLength="10"
android:numeric="decimal"
android:textColor="#00CC00"
android:textStyle="bold" />
<EditText
android:id="@+id/dia"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="#FFFFFF"
android:hint="DIA"
android:maxLength="10"
android:numeric="decimal"
android:textColor="#00CC00"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/cal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:text="Calcular"
android:textColor="#00CC00"
android:textStyle="bold" />
<Button
android:id="@+id/bor"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:text="Borrar"
android:textColor="#00CC00"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="@+id/res"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:text="Resultado"
android:textColor="#00CC00"
android:textStyle="bold" />
</LinearLayout>
package shinoda.examen;
import android.os.Bundle;
import android.app.Activity;
import android.view.View; //librerías que se usaran
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener {
EditText edtAnio, edtMes, edtDia;
TextView txtResultado; //se declaran las variables
Button btnCalcular, btnBorrar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edtAnio = (EditText) findViewById(R.id.anio);
edtMes = (EditText) findViewById(R.id.mes);
edtDia = (EditText) findViewById(R.id.dia);
txtResultado = (TextView) findViewById(R.id.res);
btnCalcular = (Button) findViewById(R.id.cal);
btnBorrar = (Button) findViewById(R.id.bor);
btnCalcular.setOnClickListener(this);
btnBorrar.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.cal:
String u = edtAnio.getText().toString();
String g = edtMes.getText().toString();
String h = edtDia.getText().toString();
if (!u.equals("") && !g.equals("")) {
int anio = Integer.parseInt(edtAnio.getText().toString());
int mes = Integer.parseInt(edtMes.getText().toString());
int dia = Integer.parseInt(edtDia.getText().toString());
if (dia == 22 && mes < 4) {
int a = (2015 - anio);
int m = (4 - mes);
txtResultado.setText(" tus años son:" + a
+ "n Tus meses son:" + m + "n Tus dias
son: 0");
}
if (dia < 22 && mes < 4) {
int a = (2015 - anio);
int d = 22 - dia;
int m = (4 - mes);
txtResultado.setText(" tus años son:" + a
+ "n Tus meses son:" + m + "n Tus dias
son:" + d);
}
if (dia > 22 && mes < 4) {
int a = (2015 - anio);
int di = dia - 22;
int d = 30 - di;
int m = (3 - mes);
txtResultado.setText(" tus años son:" + a
+ "n Tus meses son:" + m + "n Tus dias
son:" + d);
}
if (dia == 22 && mes == 4) {
int a = (2015 - anio);
txtResultado.setText(" tus años son:" + a
+ "n Tus meses son:0 n Tus dias son: 0");
}
if (dia < 22 && mes == 4) {
int a = (2015 - anio);
int d = 22 - dia;
txtResultado.setText(" tus años son:" + a
+ "n Tus meses son: 0 n Tus dias son:" +
d);
}
if (dia == 22 && mes > 4) {
int a = (2014 - anio);
int me = (mes - 4);
int m = 12 - me;
txtResultado.setText(" tus años son:" + a
+ "n Tus meses son:" + m + "n Tus dias
son: 0");
}
if (dia < 22 && mes > 4) {
int a = (2014 - anio);
int me = (mes - 4);
int m = 12 - me;
int d = 22 - 15;
txtResultado.setText(" tus años son:" + a
+ "n Tus meses son:" + m + "n Tus dias
son:" + d);
}
if (dia > 22 && mes > 4) {
int a = (2014 - anio);
int me = (mes - 5);
int m = 12 - me;
int di = dia - 22;
int d = 30 - di;
txtResultado.setText(" tus años son:" + a
+ "n Tus meses son:" + m + "n Tus dias
son:" + d);
}
} else {
txtResultado.setText("Valores incorrectos");
}
break;
case R.id.bor:
edtAnio.setText("");
edtMes.setText(""); //borra los datos que anteriormente se tenían.
edtDia.setText("");
txtResultado.setText("");
break;
}
}
}
<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="#c1caff"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/numero1"
android:layout_width="325px"
android:layout_height="30px"
android:layout_weight="1"
android:background="#e9a4ff"
android:hint="Numero 1"
android:textColor="#FFFFFF" />
<TextView
android:id="@+id/resul"
android:layout_width="325px"
android:layout_height="30px"
android:layout_weight="1"
android:background="#e9a4d3"
android:hint="Resultado"
android:textColor="#FFFFFF" />
</LinearLayout>
<Button
android:id="@+id/del"
android:layout_width="125px"
android:layout_height="match_parent"
android:background="#ffc5c5"
android:gravity="center"
android:text="DEL"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/siete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="7"
android:textStyle="bold" />
<Button
android:id="@+id/ocho"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="8"
android:textStyle="bold" />
<Button
android:id="@+id/nueve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="9"
android:textStyle="bold" />
<Button
android:id="@+id/multiplicacion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="X"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/cuatro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="4"
android:textStyle="bold" />
<Button
android:id="@+id/cinco"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="5"
android:textStyle="bold" />
<Button
android:id="@+id/seis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="6"
android:textStyle="bold" />
<Button
android:id="@+id/resta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="-"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/uno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="1"
android:textStyle="bold" />
<Button
android:id="@+id/dos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="2"
android:textStyle="bold" />
<Button
android:id="@+id/tres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="3"
android:textStyle="bold" />
<Button
android:id="@+id/suma"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="+"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/cero"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="0"
android:textStyle="bold" />
<Button
android:id="@+id/punto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="."
android:textStyle="bold" />
<Button
android:id="@+id/ac"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="AC"
android:textStyle="bold" />
<Button
android:id="@+id/division"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="/"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="@+id/igual"
android:layout_width="300px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffc5c5"
android:gravity="center"
android:text="="
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
package shinoda.calbesil;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class Calbesil extends Activity implements OnClickListener {
TextView display, anterior;
float resultado = 0, num1 = 0, num2 = 0;
int o = 0;
boolean p = false, igual = false;
Button mas, menos, por, entre;
Button DEL, AC;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calbesil);
DEL = (Button) findViewById(R.id.del);
AC = (Button) findViewById(R.id.ac);
display = (TextView) findViewById(R.id.resul);
anterior = (TextView) findViewById(R.id.numero1);
Button uno = (Button) findViewById(R.id.uno);
Button dos = (Button) findViewById(R.id.dos);
Button tres = (Button) findViewById(R.id.tres);
Button cuatro = (Button) findViewById(R.id.cuatro);
Button cinco = (Button) findViewById(R.id.cinco);
Button seis = (Button) findViewById(R.id.seis);
Button siete = (Button) findViewById(R.id.siete);
Button ocho = (Button) findViewById(R.id.ocho);
Button nueve = (Button) findViewById(R.id.nueve);
Button cero = (Button) findViewById(R.id.cero);
Button p = (Button) findViewById(R.id.punto);
Button igual = (Button) findViewById(R.id.igual);
mas = (Button) findViewById(R.id.suma);
menos = (Button) findViewById(R.id.resta);
por = (Button) findViewById(R.id.multiplicacion);
entre = (Button) findViewById(R.id.division);
uno.setOnClickListener(this);
dos.setOnClickListener(this);
tres.setOnClickListener(this);
cuatro.setOnClickListener(this);
cinco.setOnClickListener(this);
seis.setOnClickListener(this);
siete.setOnClickListener(this);
ocho.setOnClickListener(this);
nueve.setOnClickListener(this);
cero.setOnClickListener(this);
p.setOnClickListener(this);
igual.setOnClickListener(this);
mas.setOnClickListener(this);
menos.setOnClickListener(this);
por.setOnClickListener(this);
entre.setOnClickListener(this);
DEL.setOnClickListener(this);
AC.setOnClickListener(this);
}
public void deshabilitar() {
mas.setEnabled(false);
menos.setEnabled(false);
por.setEnabled(false);
entre.setEnabled(false);
}
public void habilitar() {
mas.setEnabled(true);
menos.setEnabled(true);
por.setEnabled(true);
entre.setEnabled(true);
}
public boolean validar() {
if (display.getText().equals("")) {
Toast.makeText(this, "Falta Introducir Número", Toast.LENGTH_SHORT)
.show();
return false;
} else {
if (o == 0) {
num1 = Float.parseFloat(display.getText().toString());
} else {
num2 = Float.parseFloat(display.getText().toString());
}
return true;
}
}
public void borrar() {
display.setText("");
anterior.setText("");
resultado = 0;
num1 = 0;
num2 = 0;
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.suma:
if (validar() == true) {
if (igual == true) {
resultado = num1;
igual = false;
} else {
resultado = 0;
}
anterior.setText(num1 + "+");
display.setText("");
o = 3;
p = false;
deshabilitar();
}
break;
case R.id.resta:
if (validar() == true) {
if (igual == true) {
resultado = num1;
igual = false;
} else {
resultado = 0;
}
anterior.setText(num1 + "-");
display.setText("");
o = 4;
p = false;
deshabilitar();
}
break;
case R.id.multiplicacion:
if (validar() == true) {
if (igual == true) {
resultado = num1;
igual = false;
} else {
resultado = 0;
}
anterior.setText(num1 + "*");
display.setText("");
o = 5;
p = false;
deshabilitar();
}
break;
case R.id.division:
if (validar() == true) {
if (igual == true) {
resultado = num1;
igual = false;
} else {
resultado = 0;
}
anterior.setText(num1 + "/");
display.setText("");
o = 6;
p = false;
deshabilitar();
}
break;
case R.id.uno:
if (igual == true) {
borrar();
igual = false;
}
display.append("1");
break;
case R.id.dos:
if (igual == true) {
borrar();
igual = false;
}
display.append("2");
break;
case R.id.tres:
if (igual == true) {
borrar();
igual = false;
}
display.append("3");
break;
case R.id.cuatro:
if (igual == true) {
borrar();
igual = false;
}
display.append("4");
break;
case R.id.cinco:
if (igual == true) {
borrar();
igual = false;
}
display.append("5");
break;
case R.id.seis:
if (igual == true) {
borrar();
igual = false;
}
display.append("6");
break;
case R.id.siete:
if (igual == true) {
borrar();
igual = false;
}
display.append("7");
break;
case R.id.ocho:
if (igual == true) {
borrar();
igual = false;
}
display.append("8");
break;
case R.id.nueve:
if (igual == true) {
borrar();
igual = false;
}
display.append("9");
break;
case R.id.cero:
if (igual == true) {
borrar();
igual = false;
}
display.append("0");
break;
case R.id.punto:
if (p == false && igual == false) {
display.append(".");
p = true;
} else {
if (p == false) {
if (resultado != 0) {
borrar();
}
display.append(".");
p = true;
igual = false;
}
}
break;
case R.id.ac:
borrar();
habilitar();
break;
case R.id.del:
String cad = display.getText().toString();
if (!cad.equals("")) {
char[] cadena = cad.toCharArray();
String f = "";
for (int i = 0; i <= cadena.length - 2; i++) {
f = f + cadena[i];
}
display.setText(f);
} else {
Toast.makeText(this, "No hay valores", Toast.LENGTH_SHORT)
.show();
resultado = 0;
habilitar();
}
break;
case R.id.igual:
if (validar() == true) {
switch (o) {
case 3:
resultado = num1 + num2;
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();
anterior.append("" + num2);
display.setText("" + redondear(resultado));
break;
}
}
public float redondear(float numero) {
return (float) Math.rint(numero * 100000) / 100000;
}
}
<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:gravity="center_horizontal"
android:orientation="vertical"
android:background="#C17B59"
tools:context=".Camara" >
<Button
android:id="@+id/botonCapturar"
android:layout_width="91dp"
android:layout_height="54dp"
android:background="@drawable/marco" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:background="@drawable/marco"
android:orientation="vertical">
<ImageView
android:id="@+id/imageViewFoto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="35sp"
android:layout_below="@+id/botonCapturar"
android:src="@drawable/marco" />
</LinearLayout>
</LinearLayout>
package betasel.camara;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
public class Camara extends Activity {
ImageView imagen;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camara);
imagen = (ImageView) findViewById(R.id.imageViewFoto);
Button boton = (Button) findViewById(R.id.botonCapturar);
boton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent
(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent,0);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data){
super.onActivityResult(requestCode, resultCode, data);
Bitmap bitmap = (Bitmap) data.getExtras().get("data");
imagen.setImageBitmap(bitmap);
}
}
<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="#CCCCCC"
android:orientation="vertical" >
<EditText
android:id="@+id/nombre"
android:layout_width="match_parent"
android:layout_height="60sp"
android:layout_margin="10sp"
android:background="#FFFFFF"
android:hint="Nombre"
android:maxLength="20"
android:textSize="50sp" />
<EditText
android:id="@+id/edad"
android:layout_width="match_parent"
android:layout_height="60sp"
android:layout_margin="10sp"
android:background="#FFFFFF"
android:hint="Edad"
android:maxLength="20"
android:numeric="integer"
android:textSize="50sp" />
<Button
android:id="@+id/enviar"
android:layout_width="match_parent"
android:layout_height="60sp"
android:layout_margin="10sp"
android:background="#FFFFFF"
android:hint="Enviar"
android:numeric="integer"
android:textSize="50sp" />
</LinearLayout>
<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="#CCCCCC"
android:orientation="vertical" >
<TextView
android:id="@+id/resultado"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10sp"
android:background="#FFFF89"
android:textSize="50sp"/>
</LinearLayout>
package kenji.bolsa2;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View; //librerías que se usaran
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Bolsa extends Activity implements OnClickListener {
EditText nombre, edad;
Button enviar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bolsa);
nombre = (EditText) findViewById(R.id.nombre);
edad = (EditText) findViewById(R.id.edad);
enviar = (Button) findViewById(R.id.enviar);
enviar.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.enviar) {
String n = nombre.getText().toString();
String e = edad.getText().toString();
if ((!n.equals("") || !e.equals(""))
|| (!n.equals("") && !e.equals(""))) {
Intent enviardatos = new Intent(this,
Recibe.class);
enviardatos.putExtra("nombre", n);
enviardatos.putExtra("edad", e);
startActivity(enviardatos);
} else {
Toast.makeText(this, "Falta valores",
Toast.LENGTH_LONG).show();
}
}
}
}
package kenji.bolsa2;
import android.os.Bundle;
import android.app.Activity; //Librerias que se usaran
import android.widget.*;
public class Recibe extends Activity {
TextView resultado;
String nombre = "";
int edad = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recibe);
resultado = (TextView) findViewById(R.id.resultado);
Bundle recibedatos = getIntent().getExtras();
nombre = recibedatos.getString("nombre");
edad = Integer.parseInt(recibedatos.getString("edad"));
resultado.setText("Hola!!! " + nombre + "n" + "tu edad es:"
+ edad);
}
}
<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="#ED9E10"
android:orientation="vertical"
tools:context=".SignoS" >
<EditText
android:id="@+id/dia"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="#C11A53"
android:hint="DIA"
android:maxLength="10"
android:numeric="integer"
android:textColor="#F74835"
android:textStyle="italic" />
<EditText
android:id="@+id/mes"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="#C11A53"
android:hint="MES"
android:maxLength="10"
android:numeric="integer"
android:textColor="#F74835"
android:textStyle="italic" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/pre"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#F74835"
android:hint="Preguntar"
android:textStyle="italic" />
<Button
android:id="@+id/bor"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#F74835"
android:text="Borrar"
android:textStyle="italic" />
</LinearLayout>
<TextView
android:id="@+id/res"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:background="#F74835"
android:hint="Resultado"
android:textStyle="italic" />
</LinearLayout>
package Zodiacal.zodicales;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class SignoS extends Activity implements OnClickListener {
EditText Dia, Mes;
TextView beta;
Button btnpreguntar, btnBorrar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signo_s);
Dia = (EditText) findViewById(R.id.dia);
Mes = (EditText) findViewById(R.id.mes);
beta = (EditText) findViewById(R.id.res);
btnpreguntar = (Button) findViewById(R.id.pre);
btnBorrar = (Button) findViewById(R.id.bor);
btnpreguntar.setOnClickListener(this);
btnBorrar.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.pre:
String x = Dia.getText().toString();
String y = Mes.getText().toString();
if (!x.equals("") && !y.equals("")) {
int dia = Integer.parseInt(Dia.getText().toString());
String mes = Mes.getText().toString();
if (mes.equals("Enero")) {
if (dia > 0 & dia < 32) {
beta.append("Tu eres el signo de Capricornio");
} else if (dia > 20 & dia < 32) {
beta.append("Tu eres el signo de Acuario");
}
}
else if (mes.equals("Febrero")) {
if (dia > 0 & dia < 20) {
beta.append("Tu eres el signo de Acuario");
} else if (dia > 19 & dia < 29) {
beta.append("Tu eres el digno de Piscis");
}
}
else if (mes.equals("Marzo")) {
if (dia > 0 & dia < 21) {
beta.append("Tu eres el signo de Piscis");
} else if (dia > 20 & dia < 32) {
beta.append("Tu eres el digno de Aries");
}
}
else if (mes.equals("Abril")) {
if (dia > 0 & dia < 22) {
beta.append("Tu eres el signo de Aries");
} else if (dia > 21 & dia < 32) {
beta.append("Tu eres el digno de Tauro");
}
}
else if (mes.equals("Mayo")) {
if (dia > 0 & dia < 22) {
beta.append("Tu eres el signo de Tauro");
} else if (dia > 21 & dia < 32) {
beta.append("Tu eres el digno de Geminis");
}
}
else if (mes.equals("Junio")) {
if (dia > 0 & dia < 22) {
beta.append("Tu eres el signo de Geminis");
} else if (dia > 21 & dia < 31) {
beta.append("Tu eres el digno de Cancer");
}
}
else if (mes.equals("julio")) {
if (dia > 0 & dia < 23) {
beta.append("Tu eres el signo de Cancer");
} else if (dia > 22 & dia < 32) {
beta.append("Tu eres el digno de Leo");
}
}
else if (mes.equals("Agosto")) {
if (dia > 0 & dia < 23) {
beta.append("Tu eres el signo de Leo");
} else if (dia > 22 & dia < 32) {
beta.append("Tu eres el digno de Virgo");
}
}
else if (mes.equals("Septiembre")) {
if (dia > 0 & dia < 23) {
beta.append("Tu eres el signo de Virgo");
} else if (dia > 22 & dia < 31) {
beta.append("Tu eres el digno de Libra");
}
}
else if (mes.equals("Octubre")) {
if (dia > 0 & dia < 23) {
beta.append("Tu eres el signo de Libra");
} else if (dia > 22 & dia < 32) {
beta.append("Tu eres el digno de Escorpion");
}
}
else if (mes.equals("Noviembre")) {
if (dia > 0 & dia < 23) {
beta.append("Tu eres el signo de Escorpion");
} else if (dia > 30 & dia < 17) {
beta.append("Tu eres el digno de Ofiuco");
}
else if (mes.equals("Noviembre")) {
if (dia > 30 & dia < 17) {
beta.append("Tu eres el signo de Sagitario");
}
}
}
else if (mes.equals("Diciembre")) {
if (dia > 0 & dia < 23) {
beta.append("Tu eres el signo de Sagitario");
} else if (dia > 22 & dia < 32) {
beta.append("Tu eres el digno de Capricornio");
}
}
}
break;
case R.id.bor:
Dia.setText(""); //elimina los datos anteriores
Mes.setText("");
beta.setText("");
break;
}
}
}
<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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/trojo"
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"
android:text="R:"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<SeekBar
android:id="@+id/rojo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5sp"
android:layout_weight="1"
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/tamarillo"
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="Amarillo"
android:textSize="25sp" />
<TextView
android:id="@+id/vamarillo"
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="Y:"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<SeekBar
android:id="@+id/amarillo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5sp"
android:layout_weight="1"
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/tazul"
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="Blue"
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="B:"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<SeekBar
android:id="@+id/azul"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5sp"
android:layout_weight="1"
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="5sp"
android:background="#CCCC"
android:gravity="center"
android:text="Color"
android:textSize="65sp" />
</LinearLayout>
package shinoda.color;
import android.os.Bundle;
import android.app.Activity;
import android.widget.*;
public class Color extends Activity implements
SeekBar.OnSeekBarChangeListener {
SeekBar rojo, amarillo, azul;
TextView vrojo, vamarillo, vazul, hex, color;
int r = 0, v = 0, a = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_color);
rojo = (SeekBar) findViewById(R.id.rojo);
amarillo = (SeekBar) findViewById(R.id.amarillo);
azul = (SeekBar) findViewById(R.id.azul);
hex = (TextView) findViewById(R.id.hex);
color = (TextView) findViewById(R.id.color);
vrojo = (TextView) findViewById(R.id.vrojo);
vamarillo = (TextView) findViewById(R.id.vamarillo);
vazul = (TextView) findViewById(R.id.vazul);
rojo.setOnSeekBarChangeListener(this);
amarillo.setOnSeekBarChangeListener(this);
azul.setOnSeekBarChangeListener(this);
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
switch (seekBar.getId()) {
case R.id.rojo:
r = progress;
break;
case R.id.amarillo:
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);
color += Integer.toHexString(v);
color += Integer.toHexString(a);
return color;
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
vrojo.setText("R: " + r);
vamarillo.setText("Y: " + v);
vazul.setText("B: " + a);
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
vrojo.setText("R: " + r);
vamarillo.setText("Y: " + v);
vazul.setText("B: " + a);
}
ó
GRACIAS A ESTE SISTEMA OPERATIVO UN CELULAR MOVIL YA
TIENE MAS APLICACIONES PARA SU NECESIDAD.
EN ESTE MANUAL RECABAMOS ALGUNAS APLICACIONES MUY
BASICAS PARA QUE SE PUEDA LLEGAR A UNA APLICACIÓN MAS
COMPLEJA.
APRENDIMOS LAS COSAS MAS BASICAS DE COMO CREAR UNA
APLICACIÓN ADEMAS DE QUE SUPIMOS LOS CONCEPTOS
BASICOS DE CADA UNA DE LAS APLICACIONES CREADAS.
ESTO ES EL FUTURO UN MUNDO LLENO DE TECNOLOGIA.

Más contenido relacionado

Similar a Crear Aplicaciones Android (20)

Reportesaplicacionem
ReportesaplicacionemReportesaplicacionem
Reportesaplicacionem
 
Reportes android
Reportes androidReportes android
Reportes android
 
Practicas android studio efrain
Practicas android studio efrainPracticas android studio efrain
Practicas android studio efrain
 
Practicas android studio efrain
Practicas android studio efrainPracticas android studio efrain
Practicas android studio efrain
 
Practicas android studio efrain (1)
Practicas android studio efrain (1)Practicas android studio efrain (1)
Practicas android studio efrain (1)
 
Manual de aplicaciones Moviles
Manual de aplicaciones MovilesManual de aplicaciones Moviles
Manual de aplicaciones Moviles
 
Reportes de practicas
Reportes de practicasReportes de practicas
Reportes de practicas
 
Troston lulu
Troston luluTroston lulu
Troston lulu
 
REPORTES DE PRACTICAS
REPORTES DE PRACTICASREPORTES DE PRACTICAS
REPORTES DE PRACTICAS
 
Diego
DiegoDiego
Diego
 
Reportes de actividad
Reportes de actividadReportes de actividad
Reportes de actividad
 
Acitividad 10
Acitividad 10Acitividad 10
Acitividad 10
 
Acitividad 10
Acitividad 10Acitividad 10
Acitividad 10
 
Reportes android
Reportes androidReportes android
Reportes android
 
manual
manualmanual
manual
 
manual
manualmanual
manual
 
manual
manualmanual
manual
 
Pract 5
Pract 5Pract 5
Pract 5
 
Reportes
ReportesReportes
Reportes
 
Actividad 11
Actividad 11Actividad 11
Actividad 11
 

Último

Manual - ABAS II completo 263 hojas .pdf
Manual - ABAS II completo 263 hojas .pdfManual - ABAS II completo 263 hojas .pdf
Manual - ABAS II completo 263 hojas .pdfMaryRotonda1
 
Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...
Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...
Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...Carlos Muñoz
 
el CTE 6 DOCENTES 2 2023-2024abcdefghijoklmnñopqrstuvwxyz
el CTE 6 DOCENTES 2 2023-2024abcdefghijoklmnñopqrstuvwxyzel CTE 6 DOCENTES 2 2023-2024abcdefghijoklmnñopqrstuvwxyz
el CTE 6 DOCENTES 2 2023-2024abcdefghijoklmnñopqrstuvwxyzprofefilete
 
RETO MES DE ABRIL .............................docx
RETO MES DE ABRIL .............................docxRETO MES DE ABRIL .............................docx
RETO MES DE ABRIL .............................docxAna Fernandez
 
Caja de herramientas de inteligencia artificial para la academia y la investi...
Caja de herramientas de inteligencia artificial para la academia y la investi...Caja de herramientas de inteligencia artificial para la academia y la investi...
Caja de herramientas de inteligencia artificial para la academia y la investi...Lourdes Feria
 
codigos HTML para blogs y paginas web Karina
codigos HTML para blogs y paginas web Karinacodigos HTML para blogs y paginas web Karina
codigos HTML para blogs y paginas web Karinavergarakarina022
 
NARRACIONES SOBRE LA VIDA DEL GENERAL ELOY ALFARO
NARRACIONES SOBRE LA VIDA DEL GENERAL ELOY ALFARONARRACIONES SOBRE LA VIDA DEL GENERAL ELOY ALFARO
NARRACIONES SOBRE LA VIDA DEL GENERAL ELOY ALFAROJosé Luis Palma
 
ACERTIJO DE LA BANDERA OLÍMPICA CON ECUACIONES DE LA CIRCUNFERENCIA. Por JAVI...
ACERTIJO DE LA BANDERA OLÍMPICA CON ECUACIONES DE LA CIRCUNFERENCIA. Por JAVI...ACERTIJO DE LA BANDERA OLÍMPICA CON ECUACIONES DE LA CIRCUNFERENCIA. Por JAVI...
ACERTIJO DE LA BANDERA OLÍMPICA CON ECUACIONES DE LA CIRCUNFERENCIA. Por JAVI...JAVIER SOLIS NOYOLA
 
programa dia de las madres 10 de mayo para evento
programa dia de las madres 10 de mayo  para eventoprograma dia de las madres 10 de mayo  para evento
programa dia de las madres 10 de mayo para eventoDiegoMtsS
 
Resolucion de Problemas en Educacion Inicial 5 años ED-2024 Ccesa007.pdf
Resolucion de Problemas en Educacion Inicial 5 años ED-2024 Ccesa007.pdfResolucion de Problemas en Educacion Inicial 5 años ED-2024 Ccesa007.pdf
Resolucion de Problemas en Educacion Inicial 5 años ED-2024 Ccesa007.pdfDemetrio Ccesa Rayme
 
Clasificaciones, modalidades y tendencias de investigación educativa.
Clasificaciones, modalidades y tendencias de investigación educativa.Clasificaciones, modalidades y tendencias de investigación educativa.
Clasificaciones, modalidades y tendencias de investigación educativa.José Luis Palma
 
Heinsohn Privacidad y Ciberseguridad para el sector educativo
Heinsohn Privacidad y Ciberseguridad para el sector educativoHeinsohn Privacidad y Ciberseguridad para el sector educativo
Heinsohn Privacidad y Ciberseguridad para el sector educativoFundación YOD YOD
 
Herramientas de Inteligencia Artificial.pdf
Herramientas de Inteligencia Artificial.pdfHerramientas de Inteligencia Artificial.pdf
Herramientas de Inteligencia Artificial.pdfMARIAPAULAMAHECHAMOR
 
OLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptx
OLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptxOLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptx
OLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptxjosetrinidadchavez
 
Informatica Generalidades - Conceptos Básicos
Informatica Generalidades - Conceptos BásicosInformatica Generalidades - Conceptos Básicos
Informatica Generalidades - Conceptos BásicosCesarFernandez937857
 
Neurociencias para Educadores NE24 Ccesa007.pdf
Neurociencias para Educadores  NE24  Ccesa007.pdfNeurociencias para Educadores  NE24  Ccesa007.pdf
Neurociencias para Educadores NE24 Ccesa007.pdfDemetrio Ccesa Rayme
 

Último (20)

Repaso Pruebas CRECE PR 2024. Ciencia General
Repaso Pruebas CRECE PR 2024. Ciencia GeneralRepaso Pruebas CRECE PR 2024. Ciencia General
Repaso Pruebas CRECE PR 2024. Ciencia General
 
Manual - ABAS II completo 263 hojas .pdf
Manual - ABAS II completo 263 hojas .pdfManual - ABAS II completo 263 hojas .pdf
Manual - ABAS II completo 263 hojas .pdf
 
Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...
Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...
Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...
 
el CTE 6 DOCENTES 2 2023-2024abcdefghijoklmnñopqrstuvwxyz
el CTE 6 DOCENTES 2 2023-2024abcdefghijoklmnñopqrstuvwxyzel CTE 6 DOCENTES 2 2023-2024abcdefghijoklmnñopqrstuvwxyz
el CTE 6 DOCENTES 2 2023-2024abcdefghijoklmnñopqrstuvwxyz
 
RETO MES DE ABRIL .............................docx
RETO MES DE ABRIL .............................docxRETO MES DE ABRIL .............................docx
RETO MES DE ABRIL .............................docx
 
Caja de herramientas de inteligencia artificial para la academia y la investi...
Caja de herramientas de inteligencia artificial para la academia y la investi...Caja de herramientas de inteligencia artificial para la academia y la investi...
Caja de herramientas de inteligencia artificial para la academia y la investi...
 
codigos HTML para blogs y paginas web Karina
codigos HTML para blogs y paginas web Karinacodigos HTML para blogs y paginas web Karina
codigos HTML para blogs y paginas web Karina
 
NARRACIONES SOBRE LA VIDA DEL GENERAL ELOY ALFARO
NARRACIONES SOBRE LA VIDA DEL GENERAL ELOY ALFARONARRACIONES SOBRE LA VIDA DEL GENERAL ELOY ALFARO
NARRACIONES SOBRE LA VIDA DEL GENERAL ELOY ALFARO
 
ACERTIJO DE LA BANDERA OLÍMPICA CON ECUACIONES DE LA CIRCUNFERENCIA. Por JAVI...
ACERTIJO DE LA BANDERA OLÍMPICA CON ECUACIONES DE LA CIRCUNFERENCIA. Por JAVI...ACERTIJO DE LA BANDERA OLÍMPICA CON ECUACIONES DE LA CIRCUNFERENCIA. Por JAVI...
ACERTIJO DE LA BANDERA OLÍMPICA CON ECUACIONES DE LA CIRCUNFERENCIA. Por JAVI...
 
programa dia de las madres 10 de mayo para evento
programa dia de las madres 10 de mayo  para eventoprograma dia de las madres 10 de mayo  para evento
programa dia de las madres 10 de mayo para evento
 
Resolucion de Problemas en Educacion Inicial 5 años ED-2024 Ccesa007.pdf
Resolucion de Problemas en Educacion Inicial 5 años ED-2024 Ccesa007.pdfResolucion de Problemas en Educacion Inicial 5 años ED-2024 Ccesa007.pdf
Resolucion de Problemas en Educacion Inicial 5 años ED-2024 Ccesa007.pdf
 
Clasificaciones, modalidades y tendencias de investigación educativa.
Clasificaciones, modalidades y tendencias de investigación educativa.Clasificaciones, modalidades y tendencias de investigación educativa.
Clasificaciones, modalidades y tendencias de investigación educativa.
 
Heinsohn Privacidad y Ciberseguridad para el sector educativo
Heinsohn Privacidad y Ciberseguridad para el sector educativoHeinsohn Privacidad y Ciberseguridad para el sector educativo
Heinsohn Privacidad y Ciberseguridad para el sector educativo
 
Sesión de clase: Defendamos la verdad.pdf
Sesión de clase: Defendamos la verdad.pdfSesión de clase: Defendamos la verdad.pdf
Sesión de clase: Defendamos la verdad.pdf
 
La Trampa De La Felicidad. Russ-Harris.pdf
La Trampa De La Felicidad. Russ-Harris.pdfLa Trampa De La Felicidad. Russ-Harris.pdf
La Trampa De La Felicidad. Russ-Harris.pdf
 
Herramientas de Inteligencia Artificial.pdf
Herramientas de Inteligencia Artificial.pdfHerramientas de Inteligencia Artificial.pdf
Herramientas de Inteligencia Artificial.pdf
 
OLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptx
OLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptxOLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptx
OLIMPIADA DEL CONOCIMIENTO INFANTIL 2024.pptx
 
Informatica Generalidades - Conceptos Básicos
Informatica Generalidades - Conceptos BásicosInformatica Generalidades - Conceptos Básicos
Informatica Generalidades - Conceptos Básicos
 
Neurociencias para Educadores NE24 Ccesa007.pdf
Neurociencias para Educadores  NE24  Ccesa007.pdfNeurociencias para Educadores  NE24  Ccesa007.pdf
Neurociencias para Educadores NE24 Ccesa007.pdf
 
Power Point: "Defendamos la verdad".pptx
Power Point: "Defendamos la verdad".pptxPower Point: "Defendamos la verdad".pptx
Power Point: "Defendamos la verdad".pptx
 

Crear Aplicaciones Android