[Java for Android App Development] cobogarciaj:
Hi I'm newbie on xdadevelopers and in android applications development, I'm trying to do an android app wich creates 3 objects called "Contacte". This 3 objects must be showed on the ActivityMain by preference order and for this I'm using an ArrayList to save them. When I create the ArrayList on the MainActivity I can show them correctly (in the order I want), but then for every element showed I show too one button to edit object propertied(Contacte). Using an intent I pass the object to another activity called EditaContacte from there I can change object properties, but when I save the changes and send the object back to the MainActivity the changes doesn't applied. I know there's not a good explanation...

Resume: I heave to do an app which show 3 objects with one buton each to edit object properties; the objects must be ordered by prioriti but I can't do it for change the properites on the second ativity and save the changes.

There's the "Contact" class:

public class Contacte implements Serializable {

/**
* Per poder passar l'objecte entre activities primer l'hem de serialitzar
*/
private String nom;
private String cognoms;
private String telefon;
private int horari; // 0 = horari sense definir; 1 = 24h; 2 = Mati; 3 = Tarda
private boolean principal;

/**
* Constructor sense parametres que permet crear un objecte contacte amb els
* valors predefinits
*/
public Contacte(){
nom = "Nom";
cognoms = "Cognom";
telefon = "Telefon";
horari = 0;
principal = false;
}
// Setters and Getters

The MainActivity

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Array que contindrà 3 objectes de tipus contacte, el primer serà el contacte prioritari
ArrayList<Contacte> contactes = new ArrayList<Contacte>();

// Creem els objectes que representen els contactes
Contacte c1 = new Contacte();
Contacte c2 = new Contacte();
Contacte c3 = new Contacte();

// Assignem valors al primer contacte
c1.setNom("John");
c1.setCognoms("Doe");
c1.setTelefon("632145897");
c1.setHorari(2);

// Afegim els Contactes a l'ArrayList contactes
contactes.add(c1);
contactes.add(c2);
contactes.add(c3);
// Obtenim les referencies als elements on es mostren les dades del primer contacte
TextView nom1 = (TextView)findViewById(R.id.txtNom1);
TextView cognom1 = (TextView)findViewById(R.id.txtCognom1);
TextView telefon1 = (TextView)findViewById(R.id.txtTelefon1);
RadioButton horari24h1 = (RadioButton)findViewById(R.id.rdioButtonHorari24h1);
RadioButton mati1 = (RadioButton)findViewById(R.id.rdioButtonHorariMati1);
RadioButton tarda1 = (RadioButton)findViewById(R.id.rdioButtonHorariTarda1);

// Mostrem el nom, cognoms i telefon del primer contacte per pantalla
nom1.setText(contactes.get(0).getNom());
cognom1.setText(contactes.get(0).getCognoms());
telefon1.setText(contactes.get(0).getTelefon());

}

private OnClickListener onClickListener = new OnClickListener() {
@Override
public void onClick(final View v) {
switch(v.getId()){
case R.id.edita1:

// 1. create an intent pass class name or intnet action name
Intent i = new Intent();
i.setClass(MainActivity.this, EditaContacte.class);

// 2. create person object
Contacte c = new Contacte();
c = contactes.get(0);

// 3. put person in intent data
i.putExtra("contactec", contactes);
i.putExtra("index", 0);

// 4. start the activity
startActivity(i);

break;
//	case R.id.edita2:
//DO something
//	break;
//	case R.id.edita3:
//DO something
//	break;
}

}
};

And there's the EditaContacte

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edita_contacte);

// 1. get passed intent
Intent intent = getIntent();
Contacte c = new Contacte();

// 2. get person object from intent
c = (Contacte) intent.getSerializableExtra("contacte");

// 3. get reference to person textView
EditText editaNom = (EditText) findViewById(R.id.editaNom);
EditText editaCognom = (EditText) findViewById(R.id.editaCognom);
EditText editaTelefon = (EditText) findViewById(R.id.editaTelefon);
RadioButton editaTotDia = (RadioButton) findViewById(R.id.TotDia);
RadioButton editaMati = (RadioButton) findViewById(R.id.mati);
RadioButton editaTarda = (RadioButton) findViewById(R.id.tarda);
Button edita = (Button)findViewById(R.id.edita);
edita.setOnClickListener(onClickListener);

// 4. display name & age on textView
editaNom.setText(c.getNom());
editaCognom.setText(c.getCognoms());
editaTelefon.setText(c.getTelefon());

// Deixem marcat el RadioButton segons l'horari del contacte
switch(c.getHorari()){
case 0:
editaTotDia.setChecked(false);
editaMati.setChecked(false);
editaTarda.setChecked(false);

break;
case 1:
editaTotDia.setChecked(true);
editaMati.setChecked(false);
editaTarda.setChecked(false);

break;
case 2:
editaTotDia.setChecked(false);
editaMati.setChecked(true);
editaTarda.setChecked(false);

break;
case 3:
editaTotDia.setChecked(false);
editaMati.setChecked(false);
editaTarda.setChecked(true);

break;
}

}