Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the layout inflater in an Android application? [duplicate]

Tags:

android

Possible Duplicate:
What does Layout Inflater in Android do?

What is the layout inflater used for in an Android application?

like image 574
User Avatar asked Oct 18 '10 12:10

User


People also ask

What does layout Inflater do in android?

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.

Why Inflater is used in android?

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.

What is Inflater class in android?

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.

What is a layout in android?

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.


2 Answers

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.

like image 95
cement Avatar answered Sep 22 '22 17:09

cement


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.

like image 20
Tyler Treat Avatar answered Sep 22 '22 17:09

Tyler Treat