- 1、本文档共13页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Itent传递对象
Android高手进阶教程(十七)之---Android中Intent传递对象的两种方法(Serializable,Parcelable)? ???大家好,好久不见,今天要给大家讲一下Android中Intent中如何传递对象,就我目前所知道的有两种方法,一种是 Bundle.putSerializable(Key,Object);另一种是Bundle.putParcelable(Key, Object);当然这些Object是有一定的条件的,前者是实现了Serializable接口,而后者是实现了Parcelable接口,为了让大 家更容易理解我还是照常写了一个简单的Demo,大家就一步一步跟我来吧!第一步:新建一个Android工程命名为ObjectTranDemo(类比较多哦!)目录结构如下图:
下载 (24.71 KB)
2010-8-3 22:00
第二步:修改main.xml布局文件(这里我增加了两个按钮)代码如下view plaincopy to clipboardprint??xml version=1.0 encoding=utf-8?? ?LinearLayout xmlns:android=/apk/res/android??? ? android:orientation=vertical??? ? android:layout_width=fill_parent??? ? android:layout_height=fill_parent??? ? ? ?TextView? ???? ? android:layout_width=fill_parent? ? ? ? android:layout_height=wrap_content? ? ? ? android:text=Welcome to Mr weis blog.??? ? /? ?Button? ?? ? android:id=@+id/button1??? ? android:layout_width=fill_parent??? ? android:layout_height=wrap_content??? ? android:text=Serializable??/? ?Button? ?? ? android:id=@+id/button2??? ? android:layout_width=fill_parent??? ? android:layout_height=wrap_content??? ? android:text=Parcelable??/? ?/LinearLayout? ??xml version=1.0 encoding=utf-8?LinearLayout xmlns:android=/apk/res/android? ? android:orientation=vertical? ? android:layout_width=fill_parent? ? android:layout_height=fill_parent? ? TextView??? ? android:layout_width=fill_parent ? ? android:layout_height=wrap_content ? ? android:text=Welcome to Mr weis blog.? ? /Buttonandroid:id=@+id/button1android:layout_width=fill_parentandroid:layout_height=wrap_contentandroid:text=Serializable/Buttonandroid:id=@+id/button2android:layout_width=fill_parentandroid:layout_height=wrap_contentandroid:text=Parcelable//LinearLayout??第三步:新建两个类一个是Person.java实现Serializable接口,另一个Book.java实现Parcelable接口,代码分别如下:Person.java:view plaincopy to clipboardprint?package com.tutor.objecttran;? ?import java.io.Serializable;? ?public class Person implements Serializable {? ?? ? private static final lo
您可能关注的文档
- 八年级英语上学期1-3重点短语及句型 Name.doc
- 2011中考核心词汇(一).doc
- 选修9unit3-4教案.doc
- book3第4单元 词汇自测.doc
- 哈尔滨政府名称翻译.doc
- android service 相关知识.doc
- MBA英语基础课程6-完整版.doc
- 中考英语考纲词汇用法详解(H).doc
- android复习总.doc
- 外研版七年级下册测试卷下M11.doc
- 2025届衡阳市第八中学高三一诊考试物理试卷含解析.doc
- 2025届湖南省娄底市双峰一中等五校重点中学高三第二次诊断性检测物理试卷含解析.doc
- 天水市第一中学2025届高三第二次联考物理试卷含解析.doc
- 2025届金华市重点中学高三考前热身物理试卷含解析.doc
- 2025届北京市石景山区第九中学高三第四次模拟考试物理试卷含解析.doc
- 江苏扬州市2025届高三第一次模拟考试物理试卷含解析.doc
- 2025届江苏省南通市高级中学高考物理五模试卷含解析.doc
- 广东省清远市华侨中学2025届高三第一次调研测试物理试卷含解析.doc
- 辽宁省凤城市2025届高三第五次模拟考试物理试卷含解析.doc
- 内蒙古巴彦淖尔市重点中学2025届高考仿真卷物理试卷含解析.doc
最近下载
- 武汉市2025届高中毕业生二月调研考试(二调)数学试卷(含官方答案).pdf
- 著名建筑案例分析精品课件.ppt
- 中国冠状动脉左主干分叉病变介入治疗指南.pdf VIP
- 血液净化技术的操作并发症及处理.docx VIP
- 《认识东南西北》-完整版PPT课件.pptx
- 2025年黄河水利职业技术学院单招职业技能测试题库及答案(必刷).docx VIP
- 义务教育语文课程标准(2022年版)考试题库含答案 .docx VIP
- 2025年烟台汽车工程职业学院高职单招职业技能测验历年参考题库频考版含答案解析.docx
- TED 女孩不必完美,而必要勇敢.pdf
- 2.3中国的耕地资源与粮食安全 课件 (35张PPT).pptx VIP
文档评论(0)