Layouts
  Each layout file must contain exactly one root element, which must be a View or ViewGroup object.

  After you've declared your layout in XML, save the file with the .xml extension, in your Android project's res/layout/ directory, so it will properly compile.

  When you compile your application, each XML layout file is compiled into a View resource. You should load the layout resource from your application code, in your Activity.onCreate()callback implementation. Do so by calling setContentView(), passing it the reference to your layout resource in the form of: R.layout.layout_file_name. For example, if your XML layout is saved as main_layout.xml, you would load it for your Activity like so:

  

  

  

  The at-symbol (@) at the beginning of the string indicates that the XML parser should parse and expand the rest of the ID string and identify it as an ID resource.

  The plus-symbol (+) means that this is a new resource name that must be created and added to our resources (in theR.java file).

  There are a number of other ID resources that are offered by the Android framework. When referencing an Android resource ID, you do not need the plus-symbol, but must add the android package namespace, like so:

  

  

参考:http://android.xsoftlab.net/guide/topics/ui/declaring-layout.html#load

Layouts的更多相关文章

  1. Advanced Collection Views and Building Custom Layouts

    Advanced Collection Views and Building Custom Layouts UICollectionView的结构回顾 首先回顾一下Collection View的构成 ...

  2. Designing CSS Layouts With Flexbox Is As Easy As Pie

    This article is an updated excerpt of the chapter “Restyle, Recode, Reimagine With CSS3″ from our Sm ...

  3. ExtJS笔记4 容器与布局(Layouts and Containers)

    The layout system is one of the most powerful parts of Ext JS. It handles the sizing and positioning ...

  4. grails的layouts模板页面使用

    使用方式1: layouts文件夹下新建文件,名称和Controller名称相同,例如UserController,layouts下面创建user.gsp,此时,user站点下所有的页面都将套用 us ...

  5. Android用户界面布局(layouts)

    Android用户界面布局(layouts) 备注:view理解为视图 一个布局定义了用户界面的可视结构,比如activity的UI或是APP widget的UI,我们可以用下面两种方式来声明布局: ...

  6. BootStrap入门教程 (一) :手脚架Scaffolding(全局样式(Global Style),格网系统(Grid System),流式格网(Fluid grid System),自定义(Customing),布局(Layouts))

    2011年,twitter的“一小撮”工程师为了提高他们内部的分析和管理能力,用业余时间为他们的产品构建了一套易用.优雅.灵活.可扩展的前端工具集--BootStrap.Bootstrap由MARK ...

  7. 读Qt Demo——Basic Layouts Example

    此例程主要展示用代码方式创建控件并用Layout管理类对其进行布局: 例程来自Qt5.2,如过是默认安装,代码位于:C:\Qt\Qt5.2.0\5.2.0\mingw48_32\examples\wi ...

  8. Using FireMonkey Layouts

    FireMonkey has many layout controls to choose from. Come learn the differences and how to use them t ...

  9. YIi 使用 beginContent() 和 endContent() 设定 Yii 的 layouts

    Yii 的 views/layouts 是用来放置 layouts 的目录,在默认的情况下会有 main.php 和 column1.php 和 column2.php. main.php 内容定义了 ...

  10. ASP.NET MVC- VIEW Creating Page Layouts with View Master Pages Part 4

    In this tutorial, you learn how to create a common page layout for multiple pages in your applicatio ...

随机推荐

  1. Laravel日志查看器 -- log-viewer扩展

    1.修改laravel配置文件. config\app.php 'log'=>'daily' 2.在项目目录中composer命令安装扩展:composer require arcanedev/ ...

  2. java 静态导入

  3. Qt Creator 预览QtCreator中的界面

    当在QtCreator界面编辑器中放置好布局和控件之后,组合键 Alt + Shift + R 可以实现预览功能.                       也可以通过以下方式更改快捷键: 具体路径 ...

  4. Logstash之四:logstash接收kafka数据

    3.kafka+logstash整合logstash1.5以后已经集成了对kafka的支持扩展,可以在conf配置中直接使用 vim /etc/logstash/conf.d/pay.conf inp ...

  5. HDU 2066 一个人的旅行 (Dijkstra算法)

    一个人的旅行 Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submis ...

  6. 杂项:ORM

    ylbtech-杂项:ORM 对象关系映射(英语:(Object Relational Mapping,简称ORM,或O/RM,或O/R mapping),是一种程序技术,用于实现面向对象编程语言里不 ...

  7. Parallel I/O and Columnar Storage

    Parallel I/O and Columnar Storage We begin with a high level overview of the system while follow up ...

  8. Spark 编程模型(中)

    先在IDEA新建一个maven项目 我这里用的是jdk1.8,选择相应的骨架 这里选择本地在window下安装的maven 新的项目创建成功 我的开始pom.xml文件配置 <project x ...

  9. django模板中自动加载static

    TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join( ...

  10. uva-10054-欧拉回路

    题意:一个项链上面的每一个珠子有俩种颜色,前面一个珠子后面的颜色和后面珠子的前面颜色一样,有一天它断了, 一个人去搜集,问,搜集到的珠子能不能再次串成项链 原以为是链表,原来链表这组数据过不了. 71 ...