Documentos de Académico
Documentos de Profesional
Documentos de Cultura
onCreateAndPrepareToDisplay()
onPrepareToDisplay()
onVisible()
onBeginInteraction()
onPauseInteraction()
onInvisible()
onDestroy()
[instead of
[instead of
[instead of
[instead of
[instead of
[instead of
[no change]
onCreate() ]
onRestart() ]
onStart() ]
onResume() ]
onPause() ]
onStop]
---------------------------------------------------------------------onActivityResult
------------------------------------------------------------------------------Operator Precedence
Operators
Precedence
postfix
unary
multiplicative
additive
shift
relational
equality
bitwise AND
bitwise exclusive OR
bitwise inclusive OR
logical AND
logical OR
ternary
assignment
-----------------------------------------------------------------------------resize a bitmap
android.graphics.Bitmap.createScaledBitmap
or
public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) {
int width = bm.getWidth();
int height = bm.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// create a matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
startActivity(i);}
//PASAMOS VARIABLE DIRECCION
Noticia objeto = (Noticia)getIntent().getExtras().getSerializable("("direccion")
;
--------------------------------------------------------------CAMBIAR CONTENIDO CUADRO TEXTO
et1=(EditText)findViewById(R.id.editText1);
et2=(EditText)findViewById(R.id.editText2);
tv3=(TextView)findViewById(R.id.textView3);
String valor1=et1.getText().toString();// et1 y et2 son editText
String valor2=et2.getText().toString();
int nro1=Integer.parseInt(valor1);//pasamos string a integer
int nro2=Integer.parseInt(valor2);
int suma=nro1+nro2;
String resultado=String.valueOf(suma);//pasamos integer a string
tv3.setText(resultado);
-----------------------------------------------------------MOSTRAR MENSAJE
//Mostramos un Toast
Toast.makeText(getApplicationContext(), "Mi primer Toast", Toast.LENGTH_LONG).sh
ow();
------------------------------------------------------Changing ImageView source:
Using setBackgroundResource() method:
myImgView.setBackgroundResource(R.drawable.monkey);
you are putting that monkey in the background.
I suggest the use of setImageResource() method:
myImgView.setImageResource(R.drawable.monkey);
or with setImageDrawable() method:
myImgView.setImageDrawable(getResources().getDrawable(R.drawable.monkey));
setImageDrawable(android.graphics.drawable.Drawable)
or
setImageBitmap(android.graphics.Bitmap)
----------------------------------------------------------fill_parent (en desuso y renombrado MATCH_PARENT en el Nivel API 8 y superior)
Configuracin de la presentacin de un widget a fill_parent obligar a que se expanda
para ocupar todo
el espacio que est disponible en el elemento de diseo que ha sido colocado. Es ms
o menos equivalente
a establecer el dockstyle de un formulario de control de Windows para llenar.
ReminderEditActiviy.class"
package es.greval.taskReminder;
import android.app.Activity;
import android.os.Bundle;
public class ReminderEditActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.reminder_edit);
}
}
EN EL FICHERO AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas....
...
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ReminderEditActivity"></activity>
</application>
</manifest>
CREAMOS EL FICHERO DE LA SEGUNDA PANTALLA:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
reminder_edit.xml
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:text="@string/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<requestFocus></requestFocus>
</EditText>
...
</LinearLayout>
</ScrollView>
----------------------------------------------------------Java tiene en total 8 tipos de datos.
Enteros
short - 16 bits.
int 32 bits.
long - 64 bits.
Nmeros Reales
float - 32 bits.
double - 64 bits.
Otros
boolean - 1 bit (true false, nicos valores posibles).
char - 16 bits.
String - *Cadena de caracteres*.
---------------------------------------------------------Pasar de int a String (2 maneras)
Nos hacemos del mtodo valueOf de la clase String o del toString de la clase Integ
er.
int numero = 1234;
String cadena = "";
cadena = String.valueOf(numero);
cadena= Integer.toString(numero);
default:
System.out.println("x no es equivalente a ninguna de las anteriores...")
;
break;
}
FOR
for (i = 0; i < 10; i++) {
System.out.println("Este bucle se ha repetido " + i + " veces...");
}
while (i!=10){ ++1}