Parcelable其中/当describeContents()使用? [英] Parcelable where/when is describeContents() used?

查看:1837
本文介绍了Parcelable其中/当describeContents()使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道在哪里/当Parcelable这种方法被称为?

Does anyone know where/when this method of a Parcelable is called?

 @Override
 public int describeContents() {
    return 0;
 }

它已被覆盖。但我应该考虑做一些有用的东西呢?

It has to be overriden. But should I consider doing something useful with it?

推荐答案

有一个在 Parcelable 定义的常量名为 CONTENTS_FILE_DESCRIPTOR 这意味着在 describeContents使用()以创建位掩码返回值。

There is a constant defined in Parcelable called CONTENTS_FILE_DESCRIPTOR which is meant to be used in describeContents() to create bitmask return value.

说明为 CONTENTS_FILE_DESCRIPTOR API参考是:

位掩码与describeContents()使用:每一位再presents一种被认为有整理潜力时具有特殊意义的对象

Bit masks for use with describeContents(): each bit represents a kind of object considered to have potential special significance when marshalled.

这实际上意味着:如果你需要把的FileDescriptor 对象为Parcelable你应该/必须指定 CONTENTS_FILE_DESCRIPTOR 作为回报的describeContents(),即通过价值特殊对象(在 describeContents()的说明)他们真正的意思是:的FileDescriptor

Which really means: If you need to put FileDescriptor object into Parcelable you should/must specify CONTENTS_FILE_DESCRIPTOR as return value of describeContents(), i.e. by "special object" (in describeContents()'s description) they really mean: FileDescriptor.

这整个的 Parcelable 功能查看未完成(读:有坏的设计)。还有另外一个奇怪的事情在docs:

This whole Parcelable functionality looks unfinished (read: has bad design). There is one other strange thing in the docs:

类实现Parcelable接口还必须有一个静态的,名为CREATOR,这是实现Parcelable.Creator接口的对象

Classes implementing the Parcelable interface must also have a static field called CREATOR, which is an object implementing the Parcelable.Creator interface

实施细则由人类可读的形式定义的多重继承? : - )

Implementing multiple inheritance by rules defined in human readable form? :-)

这似乎是C ++程序员设计的 Parceable 并在某些时候,他意识到:哦,该死的,没有多重继承在Java中...: - )

It seems like C++ programmer designed Parceable and at some point he realized: Oh, damn, there is no multiple inheritance in Java... :-)

这篇关于Parcelable其中/当describeContents()使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆