我是 Android 的初学者,我尝试在活动之间传递对象,对象包含其他对象,但出现错误。
一个解法?
我尝试使用 serializable 传递对象:
lALL.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View v,
int position, long arg3) {
System.out.println(position);
Locataire l = new Locataire(getResources());
l.setNom("test");
l.setPrenom("test");
Intent intent = new Intent(MainActivity.this, Etat_lieux.class);
intent.putExtra("EDL", l);
startActivity(intent);
}
});
和
public class Locataire implements Serializable{
private String ref;
private String civilite;
private String nom;
private String prenom;
private Contact contact = new Contact();
private Adresse adresse = new Adresse();
private String DG;
private boolean IsGarantPresent;
private boolean IsColocation;
private Resources res;
public Locataire(Resources res)
{
this.res = res;
}
联系方式,地址
公共类联系人实现可序列化{
protected String tel;
protected String mobile;
protected String fax;
protected String email;
protected String www;
ressource 是第一个活动的 Context getResources()