布局方式为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集合的更多相关文章

  1. .net获取select控件中的文本内容

    .net获取select控件中的文本内容 2009-11-28 21:19小V古 | 分类:C#/.NET | 浏览1374次 <select id="SecType" st ...

  2. 在Image控件中绘制文字

    //Canvas 在Image控件中绘制文字 procedure TForm1.Button1Click(Sender: TObject);begin  image1.Canvas.Font.Size ...

  3. 在RichTextBox控件中添加超链接文本

    实现效果: 知识运用: RichTextBox控件的AppendText方法 public void AppendText{string textData} //向控件中添加文本内容 和Process ...

  4. 如何写一套下拉刷新的控件?《MJRefresh原理浅析》(附Demo下载地址)

    相信大家有很多人在做项目的时候都在使用MJRefresh 控件来实现下拉刷新的功能: MJRefresh经过不断的重构与更新迭代,现在不管是功能上还是代码结构上都是相当不错的,都是很值我们去学习的. ...

  5. Delphi下使用Oracle Access控件组下TOraSession控件链接

    Delphi下使用Oracle Access控件组下TOraSession控件链接数据库,使用  orsn1.Options.Direct:=true;  orsn1.Server:=IP:Port: ...

  6. Silverlight中在MVVM模式下对DatagridRow选择控件封装

    在项目中,凡是涉及到表格的地方用的最多的控件,自然少不了DataGrid的身影,它明了的展示各种数据让人十分喜欢.现在要实现一个功能,使DataGrid具有全选和项选中的功能,如果在传统后台代码中完成 ...

  7. cocos2d-html5 简易 下拉表单 控件

    刚才在CH5的群里问了问  有没有大侠写过 下拉表单控件啊!  没人鸟窝 ,DZ老师表示非常伤心啊  ,于是乎  自己写一个把 共享给大家. 效果图上一个  仅仅实现了一个最最主要的控件  非常eas ...

  8. Asp.Net2.0下C#环境 Login控件实现用户登录

    原文:Asp.Net2.0下C#环境 Login控件实现用户登录 一.前台显示效果 二.前台代码             <asp:Login ID="Login1" run ...

  9. Atitit.ui控件---下拉菜单选择控件的实现select html

    Atitit.ui控件---下拉菜单选择控件的实现select   html 1. 调用& model的实现 1 2. -----select.jsp------ 1 1. 调用& m ...

随机推荐

  1. Red5点播和直播的实现

    (一)        Red5流媒体服务器介绍Red5是一个采用Java开发开源的Flash流媒体服务器.它支持:把音频(MP3)和视频(FLV)转换成播放流: 录制客户端播放流(只支持FLV):共享 ...

  2. HDU2066一个人的旅行(dijkstra)

    一开始拿到这个题感觉floyd可能会超,还是写了写,果然1WA+1TLE,之后觉得用dijkstra试试看看S和D会不会比较小,还是1WA+1TLE,最后还是借鉴了别人的做法. 把他的家作为起点,与他 ...

  3. 从0,1,2...n中统计0,1,2...9各出现了多少次【SWUN1597】

    题目就是说给你一个N.计算一下从0,1,2,3,4,5,,,,,,n-1,n中计算出0,1,2,3,,,,7,8,9分别出现了多少次... #include<cstdio> #includ ...

  4. json网页预览插件

  5. c# 实现IComparable、IComparer接口、Comparer类的详解

    在默认情况下,对象的Equals(object o)方法(基类Object提供),是比较两个对象变量是否引用同一对象.我们要必须我自己的对象,必须自己定义对象比较方式.IComparable和ICom ...

  6. 如何将std::string转int,double? (C/C++) (C) (template)

    http://www.cnblogs.com/oomusou/archive/2008/08/01/525647.html http://blog.sina.com.cn/s/blog_a843a88 ...

  7. 超轻量级spring模板方案

    最近从事的工作是web方面的,主要j2ee,spring jsp这些内容,由于刚入门,很多的技术都不了解.所谓初生牛犊不怕虎,刚入门,各种不顺手,比如写jsp,总是重复很多的代码,各种不爽,然后就去看 ...

  8. HR(人事管理)

    HRMS(Human Resource Management System) --人员 per_people_f --人员分配 per_all_assignments_f --要素 DECLARE l ...

  9. UVa442 Matrix Chain Multiplication

    // UVa442 Matrix Chain Multiplication // 题意:输入n个矩阵的维度和一些矩阵链乘表达式,输出乘法的次数.假定A和m*n的,B是n*p的,那么AB是m*p的,乘法 ...

  10. Nltest

    查看登陆到的DC: