居然没有发现,在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. Android上传文件到Web服务器,PHP接收文件(二)
  2. 新建android工程 没有R.java文件
  3. Android 读取 assets目录下的文件
  4. android 五种 布局文件
  5. Android安装apk文件,适配Android 7.0
  6. 《Android面试宝典》学习笔记(第五章:文件存储)

随机推荐

  1. 一键实现自动化部署(灰度发布)实践
  2. 使用 zabbix 监控 tomcat(包含jvm监控)
  3. sonar+Jenkins 构建代码质量自动化分析平
  4. 2021-03-19:给定一个二维数组matrix,其中的
  5. 干货!MySql DAL中间件总结
  6. 从MySQL的脏页说秃头 + 大肚子,拼命成老板
  7. ES 慢查询日志收集实战总结
  8. 面试题:为什么Java中的Collection类都继承
  9. 基本数据类型
  10. 别不信,你可能连 MySQL 的 Delete 都不会!