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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -