0
은 내가 Parcelable
인터페이스를 구현 Intent
을 보낼 이들과 같은 두 가지 목적이 있습니다양방향 일대일 관계에있는 두 객체를 어떻게 구획합니까?
class Foo implements Parcelable
{
private Bar bar;
public void writeToParcel(Parcel dest, int flags)
{
dest.writeParcelable(bar, flags);
}
}
class Bar implements Parcelable
{
private Foo foo;
public void writeToParcel(Parcel dest, int flags)
{
dest.writeParcelable(foo, flags);
}
}
어떻게 올바르게 Parcelable
인터페이스를 구현 할 수 있습니까? Foo
클래스의 writeToParcel
에서
이 Foo
필드없이 Bar
필드없이 Foo
인스턴스의 모든 필드와 Bar
인스턴스의 모든 필드를 쓰기 :
감사합니다. 이해합니다. 'DateTime' 필드를 포함하는 다른 객체가 있다면이 필드를 작성하기 위해'writeValue' 또는'writeTypedObject'를 사용해야합니까? – Clyky
'DateTime'이'Serializable'이거나'Parcelable'이고'DateTime'가'Parcelable' 인 경우에만'writeTypedObject'를 쓰면'writeValue'를 사용할 수 있습니다. – RadekJ