如何封装下列参数?
short[] types;从现在起我试过这个:
// Write to parcel
dest.writeValue(types);
// Read from parcel
???我怎样才能做到这一点?
发布于 2015-07-17 10:56:21
对于短数组,不能直接从包中读写。http://developer.android.com/reference/android/os/Parcel.html
你可以这样做。
// write
dest.writeInt(types.length);
for (int i = 0; i < types.length; i++) {
dest.writeInt((int) types[i]);
}
// read
len = parcel.readInt();
short[] types = new short[len];
for (int i = 0; i < len; i++) {
types[i] = (short) parcel.readInt();
}https://stackoverflow.com/questions/31473882
复制相似问题