include的简单使用
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的简单使用的更多相关文章
- Android.mk文件简单分析
Android.mk文件简单分析 一个Android.mk文件用来向编译系统描写叙述须要编译的源码.详细来说:该文件是GNUMakefile的一小部分.会被编译系统解析一次或多次. 能够在每个Andr ...
- Express入门教程:一个简单的博客
来自: http://ourjs.com/detail/56b2a6f088feaf2d031d2468 Express 简介 Express 是一个简洁而灵活的 node.js Web应用框架, ...
- 用express搭建一个简单的博客系统
转自:https://blog.csdn.net/qq_29721837/article/details/62055603 Express 简介 Express 是一个简洁而灵活的 node.js W ...
- Ruby中的include
Ruby中的include语句应注意以下两个问题: 1.include与文件无关.C语言中,#include预处理指令在编译期将一个文件的内容插入到另一个文件中.Ruby语句只是简单地产生一个指向指定 ...
- u-boot include目录 gd_t结构体 如何关联芯片指定的目录
1 u-boot /u-boot-2018.07-fmxx/include/config.h /* Automatically generated - do not edit */#define CO ...
- 【nodejs笔记3】Express基本用法,和路由控制,和模板渲染ejs
1. 路由控制的工作原理 //routes/index.js中的代码//访问主页时,调用ejs模板引擎,渲染index.ejs模板文件,生成静态页面,并显示在浏览器中.router.get('/', ...
- node.js 入门实例【转】
第1章 一个简单的博客 nswbmw edited this page 14 days ago · 38 revisions Pages 29 Home FAQ 番外篇之——使用 _id 查询 番外篇 ...
- Atitit 深入理解命名空间namespace java c# php js
Atitit 深入理解命名空间namespace java c# php js 1.1. Namespace还是package1 1.2. import同时解决了令人头疼的include1 1.3 ...
- velocity模板引擎学习(1)
velocity与freemaker.jstl并称为java web开发三大标签技术,而且velocity在codeplex上还有.net的移植版本NVelocity,(注:castle团队在gith ...
随机推荐
- I - Long Distance Racing(第二季水)
Description Bessie is training for her next race by running on a path that includes hills so that sh ...
- 为什么所有浏览器的userAgent都带Mozilla
参看下面链接:<为什么所有的浏览器的userAgent都带Mozilla>
- 详解如何在linuxmint上用源码包安装nodejs
第一步:安装依赖包 因为Linuxmint 和 Ubuntu 同属 Debian系的Linux,而且Linuxmint是建立在Ubuntu的基础上的,所以Ubuntu下的命令和包,Linuxmin ...
- PHP记录点击数方法
1.第一种方法: $id = $_GET['id']; //获取文章ID $sql = "UPDATE base SET hits = hits+1 WHERE id = '$id'&quo ...
- 'ManyRelatedManager' object is not iterable
先看下面的代码: class Worker(models.Model): departments = moels.ManyToManyField(Department, verbose_name=u& ...
- join函数——Gevent源码分析
在使用gevent框架的时候,我们经常会使用join函数,如下: def test1(id): print(id) gevent.sleep(0) print(id, 'is done!') t = ...
- 1207: C.LU的困惑
题目描述 Master LU 非常喜欢数学,现在有个问题:在二维空间上一共有n个点,LU每连接两个点,就会确定一条直线,对应有一个斜率.现在LU把平面内所有点中任意两点连线,得到的斜率放入一个集合中( ...
- SQL Server 提高创建索引速度的 2 个方法
方法 1. 使用tempdb来提速 create index index_name on table_name (column_list) with(sort_in_tempdb = on); 方法 ...
- 组队练习赛(Regionals 2012, North America - East Central NA)
A.Babs' Box Boutique 给定n个盒子,每个盒子都有长宽高(任意两个盒子长宽高不完全相同),现在选盒子的任意两面,要求x1 <= x2 && y1 <= y ...
- android开发的问题集(二)
(1)子线程对UI线程操作的简便方法 子线程方法用 Looper.prepare(); 结束时候用 Looper.loop();