开发者

Do root views of an Activity in Android have any prior knowledge of the child views that will be loaded into them?

Is there any way to query a root view of an activity for all of its child views even be开发者_JAVA百科fore the root view or its children have been inflated? I guess what I'm looking for is whether a view knows ahead of time what children it will have before it gets inflated, and can I get that list in some way. Bizarre I realize, but I think it will help me with some unconventional automation testing I'm working on. I haven't found anything in the API like this, so I'm hoping the community knows something spiff that will help.

Thanks!


I doubt it.

An Activity doesn't have any knowledge of its view (it just has its root window) until you call setContentView() in the onCreate() method.

There is a construct called ViewStub which allows you to delay inflating certain parts of the UI until you need them, but even then you wouldn't actually know anything about the child views until you inflate it.

Something else that may be of interest is the ViewTreeObserver and its subclasses. That allows you to receive notifications when a view hieararchy is changing.

Your test automation certainly does sound unconventional. Intriguing :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜