简体   繁体   English

Android View生命周期

[英]Android View Lifecycle

I am using the SemiClosedSlidingDrawer in my app. 我在我的应用程序中使用SemiClosedSlidingDrawer

Quick explain: 快速解释:

  1. Sliding drawer has handle and content part 滑动抽屉有手柄内容部分
  2. The content part is partially opened at view creation 内容部分在创建视图时部分打开

Problem: 问题:

When I create view the content part is inflated and cached then showing partially. 当我创建视图时,内容部分被充气并缓存,然后部分显示。 If I perform any operation on the main content. 如果我对主要内容执行任何操作。 It reflected to the content part of sliding drawer. 它反映到滑动抽屉的内容部分。 Even it is partially viewable. 即使它是部分可见的。

I managed to found the answer that the content is not set to GONE so only it is receiving touch events. 我设法找到了内容未设置为GONE的答案,因此只有接收触摸事件。

I have to set the content GONE after all inflation caching completed. 在完成所有通胀缓存后,我必须将内容设置为GONE。 So I need to know 所以我需要知道

Which View creation Lifecycle method called last? 哪个View创建生命周期方法最后调用? or Where to set ChildView's Visibility properties? 或者在哪里设置ChildView的可见性属性?

I can refer my slidingDrawer's content in activity and set to GONE it is working fine. 我可以在活动中引用我的slidingDrawer内容并设置为GONE它工作正常。 But there should be a proper way to fix this issue. 但应该有一个正确的方法来解决这个问题。

I don't get why you can't just set the content part to gone in onCreate() of your activity? 我不明白为什么你不能将内容部分设置为你的活动的onCreate()?

Alternatively make your own implementation of SemiClosedSlidingDrawer and override all the constructors with your own implementation. 或者,创建自己的SemiClosedSlidingDrawer实现,并使用您自己的实现覆盖所有构造函数。 Something like this: 像这样的东西:

SemiClosedSlidingDrawer() {
    super.SemiClosedSlidingDrawer();
    mContent.setVisibility(View.GONE);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM