实现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 ...
随机推荐
- ORA-01033: ORACLE initialization or shutdown in progress 实用的处理方法
ORA-01033: ORACLE initialization or shutdown in progress 实用的处理方法,此问题通常是由于电脑非正常关机造成的,我们可以用下面的方法查找出是那个 ...
- IOS学习网址
iOS定位和位置信息获取 http://www.cnblogs.com/496668219long/p/4471757.html iOS开发系列--并行开发其实很容易 http://www.cnblo ...
- 改变UIView 的位置 Center和Frame
网上找了一个,一般来说 有两种方法: 1.改变view 的Frame [cell setFrame:CGRectMake(<#CGFloat x#>, <#CGFloat y#> ...
- XSS攻击:SOHU视频XSS漏洞导致其用户成为DDOS肉鸡
XSS又叫CSS (Cross Site Script) ,跨站脚本攻击.恶意攻击者往Web页面里插入恶意html代码,当用户浏览该页之时,嵌入当中Web里面的html代码会被运行,从而达到恶意攻击用 ...
- Java网页数据采集器[下篇-数据查询]【转载】
本期概述 上一期我们学习了如何将html采集到的数据存储到MySql数据库中,这期我们来学习下如何在存储的数据中查询我们实际想看到的数据. 数据采集页面 2011-2012赛季英超球队战绩 如果是初学 ...
- delphi 动态建立WebBrower
//Delphi动态建立WebBrowerunit Main;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphi ...
- search result
https://github.com/search?l=java&p=86&q=Floating+window&type=Code&utf8=%E2%9C%93http ...
- Android 滑动效果进阶篇(五)—— 3D旋转
前面介绍了利用Android自带的控件,进行滑动翻页制作效果,现在我们通过代码实现一些滑动翻页的动画效果. Animation实现动画有两个方式:帧动画(frame-by-frame animatio ...
- iOS开发——实用篇Swift篇&项目开发常用实用技术
项目开发常用实用技术 实现拨打电话 要实现打电话功能,最简单最直接的方式便是:直接跳到拨号界面 (注意:这个需要真机调试,模拟器无效果) UIApplication.sharedApplica ...
- Aggregating local features for Image Retrieval
Josef和Andrew在2003年的ICCV上发表的论文[10]中,将文档检索的方法借鉴到了视频中的对象检测中.他们首先将图像的特征描述类比成单词,并建立了基于SIFT特征的vusual word ...