4

I am tried to understand inflator in listview but have not been understand. can anybody explain it with straightforward way with example. Thanks in advance.

Rupesh Yadav
  • 12,096
  • 4
  • 53
  • 70
Nik88
  • 1,037
  • 10
  • 21

2 Answers2

2

In a nutshell, this class is used to inflate XMLs that define Views and ViewGroups. Inflation is a process that includes: parsing of layout XMLs, creation of appropriate View objects and their addition to view hierarchy.

This is used to instantiate layout XML file into its corresponding View objects. It is never be used directly -- use getLayoutInflater() or getSystemService(String) to retrieve a standard LayoutInflater instance that is already hooked up to the current context and correctly configured for the device you are running on. For example:

LayoutInflater inflater = (LayoutInflater)context.getSystemService
      (Context.LAYOUT_INFLATER_SERVICE);

You can find more info about it here Layout resources in Android

user370305
  • 108,599
  • 23
  • 164
  • 151
0

Inflater in a ListView inflates the layout of each list item. You can set the layout to be one of the standard layouts or create your own custom layout.

Rajdeep Dua
  • 11,190
  • 2
  • 32
  • 22