Possible Duplicate:
What does Layout Inflater in Android do?
What is the layout inflater used for in an Android application?
The LayoutInflater class is used to instantiate the contents of layout XML files into their corresponding View objects. In other words, it takes an XML file as input and builds the View objects from it.
Put simply, an inflater allows you to create a View from a resource layout file so that you do not need to create everything programmatically. In your example, you inflate the layout R. layout.
This class provides support for general purpose decompression using the popular ZLIB compression library. The ZLIB compression library was initially developed as part of the PNG graphics standard and is not protected by patents. It is fully described in the specifications at the java.
A layout defines the structure for a user interface in your app, such as in an activity. All elements in the layout are built using a hierarchy of View and ViewGroup objects. A View usually draws something the user can see and interact with.
Basically it is needed to create (or fill) View based on XML file in runtime. For example if you need to generate views dynamically for your ListView items.
LayoutInflater is used instantiate XMLs that create Views. This involves parsing the XML, creating the View object, and finally adding it to the View hierarchy.
Check out the Android API for more information about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With