zoukankan      html  css  js  c++  java
  • Android Activity探索之LayoutInflater详解

    一、简介

      LayoutInflater与findViewById(int id)功能类似,主要用于查找res/layout/***下xml布局文件。而findViewById(int id)方法是查找已经加载的布局文件中具体widget控件,比如:Button,TextView等。具体作用:

    • 对于一个没有载入或者想动态载入的界面,都需要使用LayoutInflater.inflater(...)方法载入。
    • 对于一个已经载入的布局文件,可以使用Activity.findViewById(int id)方法获取界面的元素。

      LayoutInflater是一个抽象类,其声名如下:

    1 public abstract class LayoutInflater extends Object{}

      可以通过以下三种方法,获取LayoutInflater实例对象:

    1 // 调用Activity的getLayoutInflater() 
    2 LayoutInflater inflater = getLayoutInflater();
    3 LayoutInflater inflater = LayoutInflater.from(context);  
    4 LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  • 相关阅读:
    软件需求分析
    行高line-height 和vertical-align
    python中的集合基础知识
    python中字典常用的函数和用法
    python中字符串常用的函数
    day-75CRM
    day-74CRM
    day73CRM
    day-72Django源码解析
    day-71Django补充
  • 原文地址:https://www.cnblogs.com/naray/p/5297055.html
Copyright © 2011-2022 走看看