实现TableLayout布局下循环取出TableRow控件中的文字内容到list集合
布局方式为TableLayout,利于实现表单样式展现。
<!-- 详情内容区域 -->
<ScrollView
android:layout_above="@id/id_buttom_layout"
android:layout_below="@id/home_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
> <TableLayout
android:id="@+id/id_logTableRow"
style="@style/table"
android:layout_marginBottom="10dip"
android:showDividers="middle"> <TableRow
style="@style/tablelayout"
> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:gravity="right"
android:text="工单编号:"
android:textSize="@dimen/normal_text_size"
/>
<TextView
android:id="@+id/id_docNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:gravity="left"
android:textSize="@dimen/normal_text_size"
android:textColor="@color/balck"
/>
</TableRow> <TableRow
style="@style/tablelayout" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:gravity="right"
android:text="处 理 人:"
android:textSize="@dimen/normal_text_size"
/>
<TextView
android:id="@+id/id_logSolver"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:gravity="left"
android:textSize="@dimen/normal_text_size"
android:textColor="@color/balck"
/>
</TableRow> <TableRow
style="@style/tablelayout" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:gravity="right"
android:text="项目名称:"
android:textSize="@dimen/normal_text_size"
/>
<com.hxzk.ydbg.utils.views.SpinnerView
android:id="@+id/id_projectName"
android:layout_width="match_parent"
android:layout_height="42dp"
android:background="@drawable/edittext_bg_drawable"
android:layout_gravity="center_vertical"
android:textSize="@dimen/normal_text_size"
android:gravity="center"
/>
</TableRow> <TableRow
style="@style/tablelayout" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:gravity="right"
android:text="负 责 人:"
android:textSize="@dimen/normal_text_size"
/>
<TextView
android:id="@+id/id_projectLeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:gravity="left"
android:textSize="@dimen/normal_text_size"
android:textColor="@color/balck"
/>
</TableRow> <TableRow
style="@style/tablelayout"
> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:gravity="right"
android:text="客户地址:"
android:textSize="@dimen/normal_text_size"
/>
<TextView
android:id="@+id/id_projectAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:gravity="left"
android:textSize="@dimen/normal_text_size"
android:textColor="@color/balck"
/>
</TableRow> <TableRow
style="@style/tablelayout" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:gravity="right"
android:text="需求类型:"
android:textSize="@dimen/normal_text_size"
/>
<com.hxzk.ydbg.utils.views.SpinnerView
android:id="@+id/id_logType"
android:layout_width="match_parent"
android:layout_height="42dp"
android:background="@drawable/edittext_bg_drawable"
android:layout_gravity="center_vertical"
android:textSize="@dimen/normal_text_size"
android:gravity="center"
/>
</TableRow> <TableRow
style="@style/tablelayout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:gravity="right"
android:text="需求描述:"
android:textSize="@dimen/normal_text_size"
/>
<EditText
android:id="@+id/id_logDepict"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请填写需求的简单描述"
android:textSize="18sp"
android:inputType="textMultiLine"
android:minLines="3"
android:maxLines="100"
android:gravity="top"
android:background="@drawable/edittext_bg_drawable"
/>
</TableRow> <TableRow
style="@style/tablelayout" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:gravity="right"
android:text="处理结果:"
android:textSize="@dimen/normal_text_size"
/> <EditText
android:id="@+id/id_logResult"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请填写需求的处理结果"
android:textSize="18sp"
android:inputType="textMultiLine"
android:minLines="5"
android:maxLines="100"
android:gravity="top"
android:background="@drawable/edittext_bg_drawable"
/>
</TableRow> <TableRow
style="@style/tablelayout" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:gravity="right"
android:text="创建时间:"
android:textSize="@dimen/normal_text_size"
/>
<TextView
android:id="@+id/id_logCreateTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:gravity="left"
android:textSize="@dimen/normal_text_size"
android:textColor="@color/balck"
/>
</TableRow> <TableRow
style="@style/tablelayout" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:gravity="right"
android:text="处理时间:"
android:textSize="@dimen/normal_text_size"
/>
<TextView
android:id="@+id/id_logSolveTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:gravity="left"
android:textSize="@dimen/normal_text_size"
android:textColor="@color/balck"
/>
</TableRow> <TableRow
style="@style/tablelayout" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:gravity="right"
android:text="客户签字 \n时 间:"
android:textSize="@dimen/normal_text_size"
/>
<TextView
android:id="@+id/id_signTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:gravity="left"
android:textSize="@dimen/normal_text_size"
android:textColor="@color/balck"
/>
</TableRow> </TableLayout>
</ScrollView>
tablelayout
在Java代码中通过getChildCount、getChildAt获取tablelayout布局下的tablerow,然后再通过getChildCount、getChildAt获取tablerow下的子控件,最后通过instanceof校验对象类型并调用对应的方法获取文本。
/**表单区域*/
private TableLayout id_logTableRow; private ArrayList<String> titleList;
初始化:
id_logTableRow = (TableLayout) initview.findViewById(R.id.id_logTableRow);
titleList = new ArrayList<String>();
TableRow[] childs = new TableRow[id_logTableRow.getChildCount()];
for(int i=0;i<childs.length;i++){
childs[i] = (TableRow) id_logTableRow.getChildAt(i);
View[] childss = new View[childs[i].getChildCount()];
childss[0] = childs[i].getChildAt(0);
childss[1] = childs[i].getChildAt(1); String labelStr = ((TextView)childss[0]).getText().toString();//每一行的左侧标签
String infoStr = "";
/**
* 校验对象类型,然后再进行强类型转换,以便获取控件中的文本*/
if(childss[1] instanceof TextView){
infoStr = ((TextView)childss[1]).getText().toString();//每一行的左侧标签
}else if(childss[1] instanceof SpinnerView){
infoStr = ((SpinnerView)childss[1]).getText().toString();//每一行的左侧标签
}
else if(childss[1] instanceof EditText){
infoStr = ((EditText)childss[1]).getText().toString();//每一行的左侧标签
}else{
infoStr = " ";
} titleList.add(labelStr + infoStr);
}
打印结果:
for(int i=0;i<titleList.size();i++){
Log.v("WriteLogInfoWordFragment", (i+1) + ":" + titleList.get(i));
}

实现TableLayout布局下循环取出TableRow控件中的文字内容到list集合的更多相关文章
- .net获取select控件中的文本内容
.net获取select控件中的文本内容 2009-11-28 21:19小V古 | 分类:C#/.NET | 浏览1374次 <select id="SecType" st ...
- 在Image控件中绘制文字
//Canvas 在Image控件中绘制文字 procedure TForm1.Button1Click(Sender: TObject);begin image1.Canvas.Font.Size ...
- 在RichTextBox控件中添加超链接文本
实现效果: 知识运用: RichTextBox控件的AppendText方法 public void AppendText{string textData} //向控件中添加文本内容 和Process ...
- 如何写一套下拉刷新的控件?《MJRefresh原理浅析》(附Demo下载地址)
相信大家有很多人在做项目的时候都在使用MJRefresh 控件来实现下拉刷新的功能: MJRefresh经过不断的重构与更新迭代,现在不管是功能上还是代码结构上都是相当不错的,都是很值我们去学习的. ...
- Delphi下使用Oracle Access控件组下TOraSession控件链接
Delphi下使用Oracle Access控件组下TOraSession控件链接数据库,使用 orsn1.Options.Direct:=true; orsn1.Server:=IP:Port: ...
- Silverlight中在MVVM模式下对DatagridRow选择控件封装
在项目中,凡是涉及到表格的地方用的最多的控件,自然少不了DataGrid的身影,它明了的展示各种数据让人十分喜欢.现在要实现一个功能,使DataGrid具有全选和项选中的功能,如果在传统后台代码中完成 ...
- cocos2d-html5 简易 下拉表单 控件
刚才在CH5的群里问了问 有没有大侠写过 下拉表单控件啊! 没人鸟窝 ,DZ老师表示非常伤心啊 ,于是乎 自己写一个把 共享给大家. 效果图上一个 仅仅实现了一个最最主要的控件 非常eas ...
- Asp.Net2.0下C#环境 Login控件实现用户登录
原文:Asp.Net2.0下C#环境 Login控件实现用户登录 一.前台显示效果 二.前台代码 <asp:Login ID="Login1" run ...
- Atitit.ui控件---下拉菜单选择控件的实现select html
Atitit.ui控件---下拉菜单选择控件的实现select html 1. 调用& model的实现 1 2. -----select.jsp------ 1 1. 调用& m ...
随机推荐
- HDU 5794 A Simple Chess (容斥+DP+Lucas)
A Simple Chess 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5794 Description There is a n×m board ...
- 在线判题 (模拟)http://202.196.1.132/problem.php?id=1164
#include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #de ...
- 最新的支持DELPHI XE6的开发框架
支持负载均衡集群的中间件 主界面 插件管理 角色与权限 用户与权限
- Unity3D之Mecanim动画系统学习笔记(十一):高级功能应用
动作游戏 还记得读书的时候熬夜打<波斯王子>的时光,我们的王子通过跳跃穿过墙壁的小洞.在高层建筑上进行攀爬和跳跃,还有在操作失误掉下高楼和触发必死机关后使用时之沙的时光倒流功能回归死亡之前 ...
- C语言单向循环链表解决约瑟夫问题
据说著名犹太历史学家 Josephus有过以下的故事:在罗马人占领乔塔帕特后,39 个犹太人与Josephus及他的朋友躲到一个洞中,39个犹太人决定宁愿死也不要被敌人抓到,于是决定了一个自杀方式,4 ...
- android studio 2.0 Gradle HttpProxy 设置
Android Studio 一直Failed to import Gradle project: Connection timed out: connect Android Studio 2.0 里 ...
- C#关于静态与非静态的区别
C#静态方法与非静态方法的区别不仅仅是概念上的,那么他们有什么具体的区别呢?让我们通过本文向你做一下解析. C#的类中可以包含两种方法:C#静态方法与非静态方法.那么他们的定义有什么不同呢?他们在使用 ...
- Failed to load session “ubuntu” -- 12.04
在使用ubuntu 12.04的时候,之前不喜欢Unity桌面,就按照网上提示的安装了Gnome桌面,并且成功了! 可是,最近又想把Unity装回来,心想,这不就是安装一软件的活嘛,很简单!于是就卸载 ...
- Android Studio安装及主题字体配置
在2013 Google I/O 大会上,谷歌推出了自家全新的安卓软件集成开发工具 Android Studio,这是 Google 基于 IntelliJ IDEA 改动而来. 谷歌称 Androi ...
- <Android>关于EditText中setInputType和setSingleLine的冲突
近期自己开发了一个带有删除button的EditText,一方面须要设置为SingleLine,还有一方面又须要设置输入类型,起先在xml文件里设置了android:inputType类型,在自己定义 ...