Android Open Source - FragmentTutorial Demo Parcel






From Project

Back to project page FragmentTutorial.

License

The source code is released under:

Apache License

If you think the Android project FragmentTutorial listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.yanlu.android.fragment.model;
//  w w w  . j a v a 2s  .  c  o  m
import android.os.Parcel;
import android.os.Parcelable;

/**
 * User: captain_miao
 * Date: 14-5-6
 * Time: ????1:55
 */
public class DemoParcel implements Parcelable {
    private String name;
    private int id;

    /**
     * 1.????Parcelable.Creator????,?????????Person???????????????
     *      android.os.BadParcelableException:
     *      Parcelable protocol requires a Parcelable.Creator object called  CREATOR on class com.um.demo.Person
     * 2.??????????Percel??????????????????????
     * 3.??Parcelable.Creator????????????CREATOR???????????????????????
     * 4.?????Parcel????????????????????????????????????????????????????
     * 5.?????????
     */

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(name);
        dest.writeInt(id);
    }

    public static final Parcelable.Creator<DemoParcel> CREATOR = new Creator<DemoParcel>(){
        @Override
        public DemoParcel createFromParcel(Parcel source) {
            DemoParcel demoParcel = new DemoParcel();
            demoParcel.setName(source.readString());
            demoParcel.setId(source.readInt());
            return demoParcel;
        }

        @Override
        public DemoParcel[] newArray(int size) {
            return new DemoParcel[size];
        }
    };

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
}




Java Source Code List

com.yanlu.android.fragment.App.java
com.yanlu.android.fragment.MainActivity.java
com.yanlu.android.fragment.SettingsActivity.java
com.yanlu.android.fragment.frg.FragmentByXml.java
com.yanlu.android.fragment.frg.LeftFragment.java
com.yanlu.android.fragment.frg.RightFragment.java
com.yanlu.android.fragment.model.DemoDataMo.java
com.yanlu.android.fragment.model.DemoParcel.java
com.yanlu.android.fragment.net.GsonRequest.java
com.yanlu.android.fragment.net.LruBitmapCache.java
com.yanlu.android.fragment.net.RequestManager.java