实现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 ...
随机推荐
- IOS开发--数据持久化篇文件存储(二)
前言:个人觉得开发人员最大的悲哀莫过于懂得使用却不明白其中的原理.在代码之前我觉得还是有必要简单阐述下相关的一些知识点. 因为文章或深或浅总有适合的人群.若有朋友发现了其中不正确的观点还望多多指出,不 ...
- Hibernate 中createQuery与createSQLQuery
本文原址 : http://stta04.javaeye.com/blog/377633 hibernate 中createQuery与createSQLQuery 昨晚帮同事看代码到凌晨2点多,今早 ...
- [前端JS学习笔记]JavaScript function
一.函数的声明 1.1 function 命令 function methodName(params) { // code } 如下声明: function test_function(params) ...
- ListView为什么用setOnItemClick这个方法和onTouch这个方法有冲突
因为如果onTouch方法中返回true的话,这次事件就被ListView中的item控件消费了,所以不会执行ListVIew的setOnItemClick这个方法了,如果onTouch方法返回fal ...
- AndroidEventBus ( 事件总线 ) 的设计与实现
1. 功能介绍 AndroidEventBus是一个Android平台的事件总线库, 它简化了Activity.Fragment.Service等组件或者对象之间的交互,非常大程度上减少了它们之间的耦 ...
- Get和Post的参数传值
1. get是从服务器上获取数据,post是向服务器传送数据. 2. get是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应,在URL中可以看到.post是通过 ...
- 2015南阳CCPC E - Ba Gua Zhen 高斯消元 xor最大
Ba Gua Zhen Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description During the Three-Kingdom perio ...
- 进程和cpu的相关知识和简单调优方案
进程就是一段执行的程序,每当一个程序执行时.对于操作系统本身来说,就创建了一个进程,而且分配了相应的资源.进程能够分为3个类别: 1.交互式进程(I/O) 2.批处理进程 (CPU) ...
- HTTP协议报文、工作原理及Java中的HTTP通信技术详解
一.web及网络基础 1.HTTP的历史 1.1.HTTP的概念: HTTP(Hyper Text Transfer Protocol ...
- Metadata Lock原理4
http://blog.chinaunix.net/uid-28212952-id-3400571.html Alibaba 今天发生一个故障,MM复制结构(主备库),备库slave del ...