Layouts
【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 , passing it the reference to your layout resource in the form of: setContentView()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的更多相关文章
- Advanced Collection Views and Building Custom Layouts
Advanced Collection Views and Building Custom Layouts UICollectionView的结构回顾 首先回顾一下Collection View的构成 ...
- 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 ...
- ExtJS笔记4 容器与布局(Layouts and Containers)
The layout system is one of the most powerful parts of Ext JS. It handles the sizing and positioning ...
- grails的layouts模板页面使用
使用方式1: layouts文件夹下新建文件,名称和Controller名称相同,例如UserController,layouts下面创建user.gsp,此时,user站点下所有的页面都将套用 us ...
- Android用户界面布局(layouts)
Android用户界面布局(layouts) 备注:view理解为视图 一个布局定义了用户界面的可视结构,比如activity的UI或是APP widget的UI,我们可以用下面两种方式来声明布局: ...
- BootStrap入门教程 (一) :手脚架Scaffolding(全局样式(Global Style),格网系统(Grid System),流式格网(Fluid grid System),自定义(Customing),布局(Layouts))
2011年,twitter的“一小撮”工程师为了提高他们内部的分析和管理能力,用业余时间为他们的产品构建了一套易用.优雅.灵活.可扩展的前端工具集--BootStrap.Bootstrap由MARK ...
- 读Qt Demo——Basic Layouts Example
此例程主要展示用代码方式创建控件并用Layout管理类对其进行布局: 例程来自Qt5.2,如过是默认安装,代码位于:C:\Qt\Qt5.2.0\5.2.0\mingw48_32\examples\wi ...
- Using FireMonkey Layouts
FireMonkey has many layout controls to choose from. Come learn the differences and how to use them t ...
- YIi 使用 beginContent() 和 endContent() 设定 Yii 的 layouts
Yii 的 views/layouts 是用来放置 layouts 的目录,在默认的情况下会有 main.php 和 column1.php 和 column2.php. main.php 内容定义了 ...
- 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 ...
随机推荐
- WHEN STATICFILEHANDLER IS NOT STATICFILEHANDLER
I could also have called this "wildcard .NET mapping in IIS Express from web.config." I'm ...
- java DateUtils
package demoone; import java.sql.Timestamp; import java.text.ParseException; import java.text.Simple ...
- 峰Spring4学习(5)bean之间的关系和bean的作用范围
一.bean之间的关系: 1)继承: People.java实体类: package com.cy.entity; public class People { private int id; priv ...
- JAVA URI URL 区别
String urlString = "http://192.168.21.77:8080/swp/mainPage?aa=11&bb%3D22"; URI uri = U ...
- PostgreSQL下安装pg_stat_statements
一.安装过程如下:进入postgreSQL安装包的contrib/pg_stat_statements目录,执行编译和安装动作:用root用户 make && make install ...
- Eclipse中安装及配置EGit插件
转载:https://jingyan.baidu.com/article/59703552dcc5ad8fc107407e.html
- Linux下Nagios的安装与配置 及遇到的坑
原文http://www.jianshu.com/p/7bc822fa8278 不愿意看前5.6c部分可以直接跳到最后看命令. 一.Nagios简介 Nagios是一款开源的电脑系统和网络监视工具,能 ...
- c++官方文档-模版类
#include <iostream> using namespace std; template<class T> class MyPair { private: T t[] ...
- IPv4选项
IPv4数据报的首部由固定首部(20字节)和可变部分组成(40字节).选项可用于网络的测试和排错. 1:选项的组成(TLV:type-length-value) 1.1:一个字节的类型字段. 1.1. ...
- 手机端移动端的选择框mobileSelect.js使用
手机端移动端的选择框mobileSelect.js使用 文件地址:https://github.com/onlyhom/mobileSelect.js 请感兴趣的自行下载 使用过程 1 引入标签 &l ...