居然没有发现,在xml文件中可以使用include,我晕

一下为son.xml文件

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    ><Button android:text="@+id/Button01" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button><Button android:text="@+id/Button01" android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button></LinearLayout>

接下来在main.xml文件中将其include进来,如下

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    ><TextView      android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="@string/hello"    />    <include layout="@layout/son"/></LinearLayout>
运行效果不解释了。本来还在想,如果include2次,那么如何区分包含进来的控件的id呢,后来试了一下发现,不管include几次,其实都只相当于include了一次。

更多相关文章

  1. NPM 和webpack 的基础使用
  2. 【阿里云镜像】使用阿里巴巴DNS镜像源——DNS配置教程
  3. android 播放视频
  4. Android上传文件到Web服务器,PHP接收文件(二)
  5. Android(安卓)Studio中使用NDK
  6. android 超简单的下载功能,进度条 异步下载
  7. Android命令行手动编译打包详解
  8. 怎么给Android(安卓)控件添加边框(样式)?
  9. 新建android工程 没有R.java文件

随机推荐

  1. 使用浏览器查看Android(安卓)SQLite数据
  2. Android(安卓)requires compiler complia
  3. 关于xml文件中的一些常用标签的意义
  4. Android(安卓)sql数据库的Android包里面
  5. Android第三方异步网路加载库AsyncHttpCl
  6. Android(安卓)照相功能
  7. Android(安卓)如何使用GPU硬件加速
  8. 为Android加入busybox工具
  9. Android(安卓)SQLite数据库应用技巧分享
  10. Android利用Fiddler进行网络数据抓包