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

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -

javascript - Iterate over array and calculate average values of array-parts -

jQuery Ajax Render Fragments OR Whole Page -