<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    常用鏈接

    統計

    最新評論

    Activitie之間傳對象,通過Parcelable(轉)

    對象必須實現Serializable,對象代碼如下:

    Java代碼 
    1. import java.io.Serializable;  
    2.   
    3. import android.graphics.drawable.Drawable;  
    4.   
    5. /** 
    6.  * 包括軟件信息及評論 
    7.  * */  
    8. public class MyApplicationInfo extends Object implements Serializable{  
    9.       
    10.     /** 
    11.      *  
    12.      */  
    13.     private static final long serialVersionUID = -5151302508106116740L;  
    14.   
    15.     //程序名稱  
    16.     private String title;  
    17.       
    18.     //程序名稱  
    19.     private String label;  
    20.       
    21.     //程序版本  
    22.     private String version;  
    23.       
    24.     //新版本  
    25.     private String newVersion;  
    26.       
    27.     //內容介紹  
    28.     private String content;  
    29.       
    30.     //作者  
    31.     private String author;  
    32.       
    33.     //圖標鏈接  
    34.     private String icon;  
    35.       
    36.     //圖標  
    37.     private Drawable dicon;  
    38.       
    39.     //演示圖片動態數組  
    40.     private String[] Demos;  
    41.       
    42.     //價格  
    43.     private String price;  
    44.       
    45.     //總共5星,以數字形式存儲  
    46.     private String star;  
    47.       
    48.     //鏈接地址  
    49.     private String detailaddress;  
    50.       
    51.     //評論包括:評論者、評論時間、評論內容、評論星級  
    52.     private Details details;  
    53.       
    54.     //包名  
    55.     private String packageName;  
    56.       
    57.     //啟動程序Class  
    58.     private String className;  
    59.       
    60.     public String getTitle() {  
    61.           
    62.         return title;  
    63.     }  
    64.   
    65.     public void setTitle(String title) {  
    66.           
    67.         this.title = title;  
    68.     }  
    69.   
    70.     public String getVersion() {  
    71.           
    72.         return version;  
    73.     }  
    74.   
    75.     public void setVersion(String version) {  
    76.           
    77.         this.version = version;  
    78.     }  
    79.   
    80.     public String getContent() {  
    81.           
    82.         return content;  
    83.     }  
    84.   
    85.     public void setContent(String content) {  
    86.           
    87.         this.content = content;  
    88.     }  
    89.   
    90.     public String getAuthor() {  
    91.           
    92.         return author;  
    93.     }  
    94.   
    95.     public void setAuthor(String author) {  
    96.           
    97.         this.author = author;  
    98.     }  
    99.   
    100.     public String getIcon() {  
    101.           
    102.         return icon;  
    103.     }  
    104.   
    105.     public void setIcon(String icon) {  
    106.           
    107.         this.icon = icon;  
    108.     }  
    109.   
    110.     public String getPrice() {  
    111.           
    112.         return price;  
    113.     }  
    114.   
    115.     public void setPrice(String price) {  
    116.           
    117.         this.price = price;  
    118.     }  
    119.   
    120.     public String getStar() {  
    121.           
    122.         return star;  
    123.     }  
    124.   
    125.     public void setStar(String star) {  
    126.           
    127.         this.star = star;  
    128.     }  
    129.   
    130.   
    131.     public String getDetailaddress() {  
    132.           
    133.         return detailaddress;  
    134.     }  
    135.   
    136.     public void setDetailaddress(String detailaddress) {  
    137.           
    138.         this.detailaddress = detailaddress;  
    139.     }  
    140.   
    141.     public String[] getDemos() {  
    142.           
    143.         return Demos;  
    144.     }  
    145.   
    146.     public void setDemos(String[] demos) {  
    147.           
    148.         Demos = demos;  
    149.     }  
    150.       
    151.   
    152.     public Details getDetails() {  
    153.           
    154.         return details;  
    155.     }  
    156.   
    157.     public void setDetails(Details details) {  
    158.           
    159.         this.details = details;  
    160.     }  
    161.   
    162.     public String getPackageName() {  
    163.           
    164.         return packageName;  
    165.     }  
    166.   
    167.     public void setPackageName(String packageName) {  
    168.           
    169.         this.packageName = packageName;  
    170.     }  
    171.   
    172.     public Drawable getDicon() {  
    173.           
    174.         return dicon;  
    175.     }  
    176.   
    177.     public void setDicon(Drawable dicon) {  
    178.           
    179.         this.dicon = dicon;  
    180.     }  
    181.   
    182.     public String getLabel() {  
    183.           
    184.         return label;  
    185.     }  
    186.   
    187.     public void setLabel(String label) {  
    188.           
    189.         this.label = label;  
    190.     }  
    191.   
    192.     public String getNewVersion() {  
    193.           
    194.         return newVersion;  
    195.     }  
    196.   
    197.     public void setNewVersion(String newVersion) {  
    198.           
    199.         this.newVersion = newVersion;  
    200.     }  
    201.   
    202.     public String getClassName() {  
    203.           
    204.         return className;  
    205.     }  
    206.   
    207.     public void setClassName(String className) {  
    208.           
    209.         this.className = className;  
    210.     }  
    211.   
    212.       
    213.   
    214.       
    215. }  

     

    自定義:AppParcelable

    Java代碼 
    1. import android.os.Parcel;  
    2. import android.os.Parcelable;  
    3.   
    4. import com.tcad.marketassistant.vo.MyApplicationInfo;  
    5.   
    6. public class AppParcelable implements Parcelable {  
    7.   
    8.     private MyApplicationInfo info;  
    9.       
    10.     public AppParcelable(Parcel source){  
    11.           
    12.         info = (MyApplicationInfo)source.readValue(MyApplicationInfo.class.getClassLoader());  
    13.               
    14.     }  
    15.       
    16.     public AppParcelable(MyApplicationInfo info){  
    17.           
    18.         this.info = info;  
    19.     }  
    20.       
    21.     public int describeContents() {  
    22.           
    23.         return 0;  
    24.     }  
    25.   
    26.     public void writeToParcel(Parcel dest, int flags) {  
    27.           
    28.         dest.writeValue(info);  
    29.     }  
    30.   
    31.   
    32.     public static final Parcelable.Creator<AppParcelable> CREATOR = new Parcelable.Creator<AppParcelable>() {  
    33.   
    34.         public AppParcelable createFromParcel(Parcel source) {  
    35.               
    36.             return new AppParcelable(source);  
    37.         }  
    38.   
    39.         public AppParcelable[] newArray(int size) {  
    40.               
    41.         //  return new AppParcelable[size];  
    42.             throw new UnsupportedOperationException();   
    43.         }  
    44.           
    45.     };  
    46.       
    47.     public MyApplicationInfo getInfo(){  
    48.           
    49.         return info;  
    50.     }  
    51. }  

     調用代碼,發送:

    Java代碼 
    1. AppParcelable parcelable = new AppParcelable(info);  
    2. //Info為MyApplicationInfo對象            
    3.             // 發送對象  
    4.             intent.putExtra("app_parcelable", parcelable);  
    5.               
    6.             startActivity(intent);  

     接收:

    Java代碼 
    1. AppParcelable p = getIntent().getParcelableExtra("app_parcelable");  
    2.               
    3.             MyApplicationInfo info = p.getInfo();  

     

    posted on 2010-09-10 16:00 九寶 閱讀(2136) 評論(0)  編輯  收藏 所屬分類: android

    主站蜘蛛池模板: 91亚洲国产成人久久精品| 日韩免费福利视频| 特级精品毛片免费观看| a级毛片免费在线观看| 成人无码WWW免费视频| 水蜜桃视频在线观看免费播放高清| 中文字幕永久免费视频| 你好老叔电影观看免费| 免费91麻豆精品国产自产在线观看| 成全在线观看免费观看大全| 久久免费动漫品精老司机| 精品熟女少妇a∨免费久久| 亚欧免费视频一区二区三区| 黄页免费的网站勿入免费直接进入| 一二三四免费观看在线视频中文版| 在线观看免费毛片| 亚洲精品456播放| 亚洲中文字幕在线乱码| 亚洲狠狠久久综合一区77777| 亚洲白色白色永久观看| 亚洲色大成网站www久久九| 久久久久亚洲精品无码网址色欲 | 亚洲精品视频免费看| 亚洲国产av一区二区三区丶| jiz zz在亚洲| 四虎影视久久久免费观看| a级毛片在线免费| 精品女同一区二区三区免费站| 免费观看一级毛片| 国产成人精品久久亚洲| 亚洲精品线在线观看| 亚洲欧洲日韩极速播放| 免费的黄色的网站| 精品视频在线免费观看| 成年人视频免费在线观看| 国产精品无码一区二区三区免费 | 亚洲一区爱区精品无码| 亚洲综合图片小说区热久久| 久久亚洲精品国产亚洲老地址| 成年网站免费入口在线观看| 免费A级毛片无码专区|