1.事前准备

<!--在res/values/styles.xml中-->
<!--设置样式-->
<style name="RemoteButton">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_margin">3dp</item>
<item name="android:textColor">@drawable/button_text_action</item>
<item name="android:background">@drawable/button_shape_shadowed</item>
</style>
<!--res/layout/include_button-->
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android">
<Button
style="@style/RemoteButton"
/>
<Button
style="@style/RemoteButton"
/>
<Button
style="@style/RemoteButton"
/>
</TableRow>
<!--res/layout/main.xml  应用linclude-->
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*"
android:id="@+id/fragment_remove_control_table">
<include
android:layout_weight="1"
layout="@layout/include_fragment_remove_control"
/>
<include
android:layout_weight="1"
layout="@layout/include_fragment_remove_control"/>
<include
android:layout_weight="1"
layout="@layout/include_fragment_remove_control"/>
<include
android:layout_weight="1"
layout="@layout/include_fragment_remove_control"/>
</TableLayout>

2.应用Java代码获取include内容

TableLayout tableLayout = (TableLayout)v.findViewById(R.id.fragment_remove_control_table);
//利用getChild()方法获取控件内部的控件
for (int i=2; i<tableLayout.getChildCount()-1; ++i){
TableRow row = (TableRow)tableLayout.getChildAt(i);
for (int j=0; j<row.getChildCount(); ++j){
Button button = (Button)row.getChildAt(j);
button.setText(String.valueOf((i-2)*3+j+1));
button.setOnClickListener(numberOnClick);
}
}

include的简单使用的更多相关文章

  1. Android.mk文件简单分析

    Android.mk文件简单分析 一个Android.mk文件用来向编译系统描写叙述须要编译的源码.详细来说:该文件是GNUMakefile的一小部分.会被编译系统解析一次或多次. 能够在每个Andr ...

  2. Express入门教程:一个简单的博客

    来自:  http://ourjs.com/detail/56b2a6f088feaf2d031d2468 Express 简介 Express 是一个简洁而灵活的 node.js Web应用框架, ...

  3. 用express搭建一个简单的博客系统

    转自:https://blog.csdn.net/qq_29721837/article/details/62055603 Express 简介 Express 是一个简洁而灵活的 node.js W ...

  4. Ruby中的include

    Ruby中的include语句应注意以下两个问题: 1.include与文件无关.C语言中,#include预处理指令在编译期将一个文件的内容插入到另一个文件中.Ruby语句只是简单地产生一个指向指定 ...

  5. u-boot include目录 gd_t结构体 如何关联芯片指定的目录

    1 u-boot /u-boot-2018.07-fmxx/include/config.h /* Automatically generated - do not edit */#define CO ...

  6. 【nodejs笔记3】Express基本用法,和路由控制,和模板渲染ejs

    1. 路由控制的工作原理 //routes/index.js中的代码//访问主页时,调用ejs模板引擎,渲染index.ejs模板文件,生成静态页面,并显示在浏览器中.router.get('/', ...

  7. node.js 入门实例【转】

    第1章 一个简单的博客 nswbmw edited this page 14 days ago · 38 revisions Pages 29 Home FAQ 番外篇之——使用 _id 查询 番外篇 ...

  8. Atitit  深入理解命名空间namespace  java c# php js

    Atitit  深入理解命名空间namespace  java c# php js 1.1. Namespace还是package1 1.2. import同时解决了令人头疼的include1 1.3 ...

  9. velocity模板引擎学习(1)

    velocity与freemaker.jstl并称为java web开发三大标签技术,而且velocity在codeplex上还有.net的移植版本NVelocity,(注:castle团队在gith ...

随机推荐

  1. react tab选项卡切换

    Tab选项卡切换是个很常见也很简单的小功能,用原生js和jq去写的话可能不到20行代码就搞定so easy.但是用react去实现就没那么容易了(是自己react比较菜).由于最近在重新学习react ...

  2. HDU 1068 - Girls and Boys

    求一个集合最多几个人,其之间任意两人没有暧昧关系. 二分图匹配 最大独立集 = 总点数 - 最大匹配数 匈牙利算法 因为每个同学都在二分图的两侧 当 A与B匹配时,B与A也匹配 所以 所求的最大匹配数 ...

  3. W - Bitset(第二季水)

    Description Give you a number on base ten,you should output it on base two.(0 < n < 1000)      ...

  4. 屏蔽鼠标右键功能JS

    <script language="Javascript">     function hiderightKey(){    return false; } docum ...

  5. 原生化:AnDevCon 2014 McVeigh 的主题演讲

    作者:Jeff McVeigh(Intel) 基于(至少部分)NDK的原生安卓应用程序占现在前1000 强的 60% 以上.该增长的原因很简单:开发商需要为用户提供超卓的体验(包括灵敏的反应.与丰富的 ...

  6. 资源回收 left

    select DISTINCT human.tid,log_pv_change.systafftid from human left join human_user on human.tid=huma ...

  7. MySQL load data infile

    语法: load data [low_priority] [local] infile ‘file_path' [replace] [ignore] into table table_name [(c ...

  8. Java 并发专题 :FutureTask 实现预加载数据 在线看电子书、浏览器浏览网页等

    继续并发专题~ FutureTask 有点类似Runnable,都可以通过Thread来启动,不过FutureTask可以返回执行完毕的数据,并且FutureTask的get方法支持阻塞. 由于:Fu ...

  9. BootStrap框架写的致敬乔布斯的网页

    http://codepen.io/Gabyler/pen/oxjRYj <div class="container"> <div class="jum ...

  10. 全国计算机等级考试二级教程-C语言程序设计_第2章_C程序设计的初步知识

    正负号与被除数一致. 3 % (-5) == 3 (-3) % 5 == -3 不用求余运算符,求出余数. int x, y; 答:x - x / y * y; const int i = 10; c ...