android arcelable 传递 boolean值

来源:互联网 发布:淘宝如何进行身份认证 编辑:程序博客网 时间:2024/06/07 01:14

转载地址:http://blog.csdn.net/zgf1991/article/details/24319979

http://stackoverflow.com/questions/6201311/how-to-read-write-a-boolean-when-implementing-the-parcelable-interface?answertab=votes#tab-top



[java] view plaincopy在CODE上查看代码片派生到我的代码片
  1. Here's how I'do it...  
  2.   
  3. writeToParcel:  
  4.   
  5. dest.writeByte((byte) (myBoolean ? 1 : 0));     //if myBoolean == true, byte == 1  
  6. readFromParcel:  
  7.   
  8. myBoolean = in.readByte() != 0;     //myBoolean == true if byte != 0  

0 0