Here's how I'd do it...
writeToParcel:
dest.writeByte((byte)(myBoolean ?1:0));//if myBoolean == true, byte == 1
readFromParcel:
myBoolean =in.readByte()!=0;//myBoolean == true if byte != 0
Parcelable 接口布尔类型读写
本文介绍了一种在实现 Parcelable 接口时布尔类型的高效读写方法。通过将布尔值转换为字节来进行存储,可以利用 0 和非 0 的特性来判断布尔值的真假状态。
源自:http://stackoverflow.com/questions/6201311/how-to-read-write-a-boolean-when-implementing-the-parcelable-interface?answertab=votes#tab-top
|
Here's how I'd do it... writeToParcel:
readFromParcel:
| |
|
I think
|
|
518