when you run setContentView(layout file name)
, you can run findViewById(id of the widget)
. You dont need to do something like xyz.findViewById
. The context of your app is set to that layout file and all findBiewById
call will refer to that layout file.
There are cases when you need to pick up one more layout file, like a CustomDialog, ListElement or a Custom Toast. At this time you wont want to create a Activity just for these small UI components, that that time you programmatically need to get a programmatic reference to your layout file, so that you can run findViewById on it.
Inflate, blows the layout like a balloon and give you the balloon for you to watch around it all the colors and objects drawn on it :). Inflate gives you the object reference to that layout to call findViewById on.
Hope this clears.