I am a newbie to android, I know this question has already been asked but i couldn't get a satisfactory explanation. My doubts are:
I hope the questions is clear, if not please say so in the comments.
I myself was also confused about what was the real purpose of attachToRoot
in inflate
method. After a bit of UI study, I finally got the answer:
parent:
in this case is the widget/layout that is surrounding the view objects that you want to inflate using findViewById().
attachToRoot:
attaches the views to their parent (includes them in the parent hierarchy), so any touch event that the views recieve will also be transfered to parent view. Now it's upto the parent whether it wants to entertain those events or ignore them. if set to false, they are not added as direct children of the parent and the parent doesn't recieve any touch events from the views.
Hope this clears the confusion