码迷,mamicode.com
首页 > 其他好文 > 详细

Layouts

时间:2017-01-08 23:54:46      阅读:389      评论:0      收藏:0      [点我收藏+]

标签:android   .com   rest   tor   cat   amp   symbol   blog   identify   

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

标签:android   .com   rest   tor   cat   amp   symbol   blog   identify   

原文地址:http://www.cnblogs.com/tekkaman/p/6263018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!