AD

Understanding of LayoutInflater android

Inflater English means expansion in Android should be extended the meaning of it.
LayoutInflater role similar to findViewById (), difference is LayoutInflater is to come under the xml layout folder layout files, and instantiate! The findViewById () is to find the specific one of the specific widget xml control (such as: Button, TextView, etc.).

There are many places she can use, such as BaseAdapter the getView, custom made in view of the Dialog widget components, etc.
It uses two kinds:

Java code

  1. view plaincopy to clipboardprint?
  2. LayoutInflater inflater = LayoutInflater.from (this);
  3. View view = inflater.inflate (R.layout.ID, null);
  4. Or simply, and as a:
  5. View view = LayoutInflater.from (this). Inflate (R.layout.ID, null);


Another method:

Java code

  1. view plaincopy to clipboardprint?
  2. LayoutInflater inflater = (LayoutInflater) getSystemService (LAYOUT_INFLATER_SERVICE);
  3. View view = inflater.inflate (R.layout.ID, null);


The above two methods are essentially the same, see the following source code, form () call is getSystemService ():

Java code

  1. Java code
  2. public static LayoutInflater from (Context context) {
  3. LayoutInflater LayoutInflater =
  4. (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
  5. if (LayoutInflater == null) {
  6. throw new AssertionError ("LayoutInflater not found.");
  7. }
  8. return LayoutInflater;
  9. }


In addition getSystemService () is a very important Android API, which is the Activity of a method according to the incoming NAME to obtain the corresponding Object, and then converted into the corresponding target. The following describes the system corresponding service.

Incoming Name The returned object Explain
WINDOW_SERVICE WindowManager Management program to open the window
LAYOUT_INFLATER_SERVICE LayoutInflater Made in the definition of the view xml
ACTIVITY_SERVICE ActivityManager Management application system status
POWER_SERVICE PowerManger Power Service
ALARM_SERVICE AlarmManager Alarm service
NOTIFICATION_SERVICE NotificationManager Status bar service
KEYGUARD_SERVICE KeyguardManager Keypad lock service
LOCATION_SERVICE LocationManager Location services, such as GPS
SEARCH_SERVICE SearchManager Search service
VEBRATOR_SERVICE Vebrator Phone vibration service
CONNECTIVITY_SERVICE Connectivity Network connection service
WIFI_SERVICE WifiManager Wi-Fi service
TELEPHONY_SERVICE TeleponyManager Telephone service
标签: java code, quot, source code, code java, api, two kinds, target, application system, management application, management program, android, layout files, corresponding service, window layout, inflater, dialog widget
分类: Industry
时间: 2011-07-23

相关文章

  1. The LayoutInflater android

    Transfer from: http://weizhulin.blog.51cto.com/1556324/311450 Hello, everybody we talked about this section is ...
  2. Understanding of the first week of android

    android first met, I wrote a state school - the initial small A, feel quite lovely. This is a day to see Chan ...
  3. Understanding Density Independence in Android

    Background Android is a mobile operating system with very few limitations on its devices' hardware. Manufactur ...
  4. Professional Android 2 Development - 2

    WHAT THIS BOOK COVERS Chapter 1 introduces Android, including what it is and how it fits into existing mobile ...
  5. android LayoutParams briefly understand the example

    Simply talk about their own understanding of the android LayoutParams it, xh write the article is low-level se ...
  6. Android Development FAQ

    Android Getting Started FAQ 1, Q: What is Android? A: Android means the original meaning of the term "rob ...
  7. Detailed Android Animation Framework, Part 1

    IBM DW discovered in an excellent article, can not help but want to turn around, mainly on the Android Tween a ...
  8. android's theory does not require a lot of free memory [depth analysis]

    Particularly at night do not care about the size of the remaining memory In fact, many people are accustomed t ...
  9. anroid transparent mode in the pop-up box

    This article is my pro-essays, but the code referred to below as I write this post is not aimed at recording t ...
  10. 最简单直接碎片操作,动态增删改(1)

    新建activity继承fragmentactivity 在布局文件中拖入一个layout,起个名字比如fragmentlayout 新建一个class,继承fragment 新建一个layout,在里面随便放几个控件 ...
  11. android in LayoutInflater

    Transfer from: http://weizhulin.blog.51cto.com/1556324/311450 Hello, everybody we talked about this section is ...
  12. The use Android in LayoutInflater

    LayoutInflater use, in the actual development of species LayoutInflater this class is very useful, its role is ...
  13. (Transfer) Android Interview --- talk about your understanding of Activity (Interview will be asked.)

    This article will relate to the following content Activity of the life cycle of a second to become a window Ac ...
  14. LayoutInflater use android

    Species LayoutInflater in the actual development of this class is very useful, its role is similar to findView ...
  15. Android in LayoutInflater class

    Inflater English means expansion, probably in the android in the expansion of the meaning of it. LayoutInflate ...
  16. android LayoutInflater use the sample

    Hello, everybody is talking about in this section we use LayoutInflater, LayoutInflater species in the actual ...
  17. Android learning experiences of three - Activity in the understanding of

    This article will relate to the following content Activity of the life cycle of a second to become a window Ac ...
  18. The fourth learning experience Android - Android NDK understanding.

    1 Introduction June 26, Google Android released NDK, causing a lot of fat people's interest. NDK full name: Na ...
  19. Android Interview Activity --- talk about your understanding of (the interview will be asked)

    This article will relate to the following content Activity of the life cycle of a second to become a window Ac ...