zoukankan      html  css  js  c++  java
  • Activity传递对象的方法

    1. //Serializeable传递对象的方法    
    2.         public void SerializeMethod(){    
    3.             Person mPerson = new Person();    
    4.             mPerson.setName("frankie");    
    5.             mPerson.setAge(25);    
    6.             Intent mIntent = new Intent(this,ObjectTranDemo1.class);    
    7.             Bundle mBundle = new Bundle();    
    8.             mBundle.putSerializable(SER_KEY,mPerson);    
    9.             mIntent.putExtras(mBundle);    
    10.                 
    11.             startActivity(mIntent);    
    12.         }    
    13.         //Pacelable传递对象方法    
    14.         public void PacelableMethod(){    
    15.             Book mBook = new Book();    
    16.             mBook.setBookName("Android Tutor");    
    17.             mBook.setAuthor("Frankie");    
    18.             mBook.setPublishTime(2010);    
    19.             Intent mIntent = new Intent(this,ObjectTranDemo2.class);    
    20.             Bundle mBundle = new Bundle();    
    21.             mBundle.putParcelable(PAR_KEY, mBook);    
    22.             mIntent.putExtras(mBundle);    
    23.                 
    24.             startActivity(mIntent);    
    25.         }    
    26.         //铵钮点击事件响应  
    请注明出处,此文档来自“善思善学”。
  • 相关阅读:
    STM32 printf 方法重定向到串口UART
    STM32F401CCU6与MFRC522接线及读取示例
    Keil MDK5 STM32F401CCU6开发环境配置
    Keil MDK5 STM32F103C8T6开发环境配置
    RFID EPC Class1 Gen2电子标签笔记
    Ubuntu20.04下的ESP8266环境
    Centos7使用memtester测试内存
    内核5.4以上, Realtek 8111网卡初始化失败
    Centos7的KVM安装配置详解
    Python抓取网页例子
  • 原文地址:https://www.cnblogs.com/gtgl/p/3927169.html
Copyright © 2011-2022 走看看