布局方式为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. 教程-在F9后提示内存错误,点击了乎略,之后怎么取消乎略?

    问题现象:F9后,调试程序,提示内存错误,点击了“乎略”.之后再也没有出现错误了.可是想改这个BUG时,没法取消乎略了. 问题原因:在DLEPHI的选项中是这么一个地方是可以设置的. 问题处理:打开D ...

  2. CodeForces 455A Boredom (DP)

    Boredom 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/G Description Alex doesn't like b ...

  3. ds18b20里的 温度值正负判断 为什么要判断大于6348 ,为什么取这个值?

    http://zhidao.baidu.com/question/576118682.html?quesup2&oldq=1

  4. IP访问SQL数据库设置

    http://wenku.baidu.com/link?url=mnjuPMo9qJvzluCHEvqVDawpuloKeGla05a2L3UtqzD_bF1VJMb7jHY4SBhuYH3-K_xF ...

  5. java命令行运行jar里的main类

    一般运行包含manifest的jar包,可以使用 java -jar <jar-file-name>.jar 如果jar里没有 manifest,则可以使用 java -cp foo.ja ...

  6. JdbcTemplate增删改查

    1.使用JdbcTemplate的execute()方法执行SQL语句 jdbcTemplate.execute("CREATE TABLE USER (user_id integer, n ...

  7. flex 简单跑马灯效果(竖着显示)

    <mx:Move id="move_area" target="{VBox_AreaWarning}"/> //move效果,模拟跑马灯 <s ...

  8. Get-ChildItem参数之 -Exclude,Filter,Recurse应用

    $p = "D:\PSScript" gci $p -Exclude "UpdateLog" #排除子目录"UpdateLog",但是后面不 ...

  9. Codeforces Round #Pi (Div. 2) B. Berland National Library 模拟

    B. Berland National LibraryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...

  10. .NET中的三种Timer的区别和用法

    最近正好做一个WEB中定期执行的程序,而.NET中有3个不同的定时器.所以正好研究研究.这3个定时器分别是: //1.实现按用户定义的时间间隔引发事件的计时器.此计时器最宜用于 Windows 窗体应 ...