android - when to call view's GetParent method, how is view's life-cycle -
when call view's getparent method in constructor, returns null. should call method view`s parent. thanks
it returns null because in constructor view doesn't have parent yet. gets parent when add view view doing addview(yourview); short example:
linearlayout layout = new linearlayout(context); yourview yourview = new yourview(context); // yourview constructor gets called layout.addview(yourview); // parent gets set layout
Comments
Post a Comment