当前位置: 首页 > news >正文

搬家网站建设公司西安是哪个省市

搬家网站建设公司,西安是哪个省市,做竞价推广的网站要求,网站建设海淀一、前言 这篇文章主要针对Serialiable和Parcelable接口来传递对象。呈现的功能是跳转到另一个界面#xff0c;然后通过toast展现我收到的数据。 二、使用Serialiable接口传递数据 1.创建需要传递的对象 //必须实现Serializable接口#xff0c;此对象才有传递的资格 publ…一、前言 这篇文章主要针对Serialiable和Parcelable接口来传递对象。呈现的功能是跳转到另一个界面然后通过toast展现我收到的数据。 二、使用Serialiable接口传递数据 1.创建需要传递的对象 //必须实现Serializable接口此对象才有传递的资格 public class Student implements Serializable {public int id;public String name;public int age;}2.传数据 /*** 跳转到Serialiable2Activity* param view*/public void startActivity(View view) {Intent intent new Intent(this, Serialiable2Activity.class);//传递对象到Serialiable2ActivityStudent student new Student();student.id 9;student.name Anglin;student.age 33;intent.putExtra(student,student);startActivity(intent);} 3.接收数据 Intent intent getIntent();Student student (Student) intent.getSerializableExtra(student);//提示显示Toast.makeText(this, student.id student.id student.namestudent.name student.age student.age,Toast.LENGTH_SHORT).show(); 二、使用Parcelable接口传递数据 1.创建需要传递的数据对象 //成为Parcelable的子类就具备传递数据的资格 public class ParcelableStudent implements Parcelable {public ParcelableStudent() {}//我们自己定义的成员public String name;public int age;//TODO 读取的数据和写入的数据一定要一致否则会报错//从Parcel对象里面读出来赋值给成员//构造函数protected ParcelableStudent(Parcel in) {//这个函数的意义就是从Parcel读取数据赋值给name和agename in.readString();age in.readInt();}//把属性写入到Parcel 对象中去Overridepublic void writeToParcel(NonNull Parcel parcel, int i) {parcel.writeString(name);parcel.writeInt(age);}//先不管是系统扩展用的Overridepublic int describeContents() {return 0;}//静态公开的成员Parcelable内部会调用。 一定要有 自动生成 或者从文档中复制不需要去写。public static final CreatorParcelableStudent CREATOR new CreatorParcelableStudent() {//创建ParcelableStudent对象 并且Parcel对象构建好传递给ParcelableStudent成员数据就可以从Parcel获取了Overridepublic ParcelableStudent createFromParcel(Parcel in) {return new ParcelableStudent(in);}//Overridepublic ParcelableStudent[] newArray(int size) {return new ParcelableStudent[size];}}; } 2.传送数据 public void startActivity(View view) {Intent intent new Intent(this,Parcelable2Activity.class);ParcelableStudent student new ParcelableStudent();student.age 20;student.name Anglin;intent.putExtra(student,student);startActivity(intent);} 3.接收数据 Intent intent getIntent();ParcelableStudent student intent.getParcelableExtra(student);//显示Parcelable1Activity 传递过来的对象 里面的数据Toast.makeText(this, student.name student.name student.age student.age, Toast.LENGTH_SHORT).show(); 四、总结 那么在编写android代码 的时候这两个我们改选择使用哪个呢一般我们会选择使用Parcelabe因为parcelable的性能更高。Serialiable面向jvm使用java序列化的形式传递对象的。android平台的虚拟机更适合Parcelable。 所以android开发必须使用Parcelabe因为这个是支持  兼容安卓虚拟机。我们主推的方式
http://www.zqtcl.cn/news/925710/

相关文章:

  • 手机网站怎么做SEO优化gzip压缩 wordpress
  • 上下框架 网站app营销的核心是什么
  • 网站开发哪里有培训wordpress 主题 网址导航
  • 深圳市宝安区怎么样百度禁止seo推广
  • 手机电商网站 模板常熟做网站优化
  • 免费的logo设计网站网页设计与制作dw
  • 线上调研问卷在哪个网站上做网页设计学生作业
  • 云南高端网站建设网页设计工作室选址依据
  • 免费的编程自学网站互联网公司网站建设ppt
  • 免费发帖的网站网站空间服务器费用
  • 商城类的网站一般怎么做做ps从哪个网站上下载图片大小
  • 怎么做网站链接支付免费推广网站搭建
  • 威海 网站建设刚刚北京传来重大消息
  • 深圳返利网站开发做网站版权怎么写
  • 上传网站内容做社交电商第一步怎么做
  • 网站icp查询系统wordpress 页面 首页
  • wordpress安装教程wamp搜索引擎优化的英文缩写是什么
  • 成都旅行社网站建设网站建设包含哪些方面
  • 找不到网站后台怎么办韩国网站域名分类
  • 建设商务网站作用积极参与网站信息建设工作
  • 网站开发阶段Oss怎么做静态网站
  • 做科学小制作的视频网站怎么才能建立自己的网站啊
  • 跳蚤市场网站开发背景网站优点
  • 长春网站建设方案咨询怎么做自己的网站平台
  • 网站建设谈单技巧做网站建设科技公司
  • 品牌网站建设4a小蝌蚪网页设计分类
  • 域名注册以后会给你一个账户名密码上传做好的网站文化网站建设需要的功能
  • 企业站用wordpress做好吗那些做环保网站的好
  • 天津有哪些有名的网站建设公司商城网站模板免费
  • 安徽省途顺建设工程有限公司网站制作网站公