【发布时间】:2013-07-13 00:26:10
【问题描述】:
我是 Android 的初学者,我尝试在活动之间传递对象,对象包含其他对象,但出现错误。
解决方案?
我尝试通过可序列化的对象传递:
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;
}
联系方式,地址
公共类Contact实现Serializable{
protected String tel;
protected String mobile;
protected String fax;
protected String email;
protected String www;
而 ressource 是第一个活动的 Context getResources()
【问题讨论】:
-
粘贴堆栈跟踪,以便我们更好地查看错误
-
Contact,Adresse,Resources等呢?他们是Serializable吗? -
error is parcelable遇到ioexception写入可序列化对象资源
标签: android android-activity serializable