Hi!!
I'm starting programming in Android and I'm creating a very simple 2
activities app following a tutorial. Here is the code of both activities:
1-
package android.nacho.Textpsycologico;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.nacho.Textpsycologico.R;
public class TestPsycologico extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_psycologico);
//Localizar los controles
final EditText txtNombre = (EditText)findViewById(R.id.TxtNombre);
final Button btnStart = (Button)findViewById(R.id.BtnStart);
btnStart.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//Creamos el Intent
//Intent intent = new Intent(TestPsycologico.this,
TestPsyNombre.class);
//Creamos la información a pasar entre actividades
Bundle b = new Bundle();
b.putString("NOMBRE", txtNombre.getText().toString());
//Añadimos la información al intent
intent.putExtras(b);
//Iniciamos la nueva actividad
startActivity(intent);
}
});
}
}
2-
package android.nacho.Textpsycologico;
import android.os.Bundle;
import android.widget.TextView;
import android.app.Activity;
public class TestPsyNombre extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_psy_nombre);
//Localizar los controles
TextView TxtZodiac = (TextView)findViewById(R.id.TxtZodiac);
//Recuperamos la información pasada en el intent
Bundle bundle = this.getIntent().getExtras();
//Construimos el mensaje a mostrar
TxtZodiac.setText("Hola " + bundle.getString("NOMBRE") + "Choose
your Zodiac Sign");
}
}
The problem is when I lauch the application it just stop before start doing
anything. I have detected that the problem is in the first code when I call
the function:
btnStart.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
...
}};
Could someone tell me what I'm doing wrong?
Than you ver much for your time
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en