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

一下为son.xml文件


Java代码 <?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进来,如下


Java代码 <?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. 一个简单的iPhone项目及代码
  4. android背景选择器selector用法汇总
  5. Android(安卓)无法查看外部依赖jar的源码的问题
  6. Android读取Excel文件
  7. android中json文件的写法
  8. exp: 修改Android中strings.xml文件, 动态改变数据
  9. Android(安卓)开发环境入门

随机推荐

  1. 国内几大Android应用市场试用小记——开
  2. android 解决wifi断线不稳定的问题-终极
  3. Android实现仿QQ登录可编辑下拉框
  4. Android广播机制——广播的注册
  5. 让 Android 应用提交更简单——用Worktil
  6. Android基于监听的事件处理机制
  7. 关于Android SDK工具Lint的误报:Class ref
  8. android网络监听事件机制(kernel, c++, ja
  9. Kotlin 风险高、RxJava 已过时,Android 原
  10. Android实现EventBus登录界面与传值(粘性