开发者

When to use getparent()

In my custom view I need to use the getParent method and set the visibility on some of it's child views depending on my custom view's state. The problem is that开发者_JAVA技巧 I want to instantiate the child views just once. Where is the best place to do this?


I'm not exactly sure what you want to do. But if all of this is occurring in the same Activity screen why don't you just assign ids (e.g. android:id="@+id/someId" to your elements in the layout.xml file.

This way you can reference any element programatically in your code by calling:

View someView = findViewById(R.id.someId);

I am unclear why you would need to call getParent. If you are trying to manipulate views in a different activity then I think you will need to use a Handler.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜