android 详细信息显示界面的思路
来源:互联网 发布:mac safari关闭标签 编辑:程序博客网 时间:2024/06/06 00:25
开发的时候,有时候会遇到类似下面这种,需要显示大量数据的界面:
控件量很大,需要定义很多的textView 之类的东西,还需要用relativeLayout 来控制什么左对齐右对齐,这里有提供2种相对简便的方法。
方法1:自定义一个控件,此控件包含一横条的布局;
定义一个叫TextTextView的控件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<
LinearLayout
xmlns:android
=
"http://schemas.android.com/apk/res/android"
android:layout_width
=
"fill_parent"
android:layout_height
=
"fill_parent"
android:orientation
=
"horizontal"
android:layout_marginTop
=
"3dip"
android:layout_marginBottom
=
"3dip"
>
<
TextView
android:layout_marginLeft
=
"15dip"
android:text
=
"TextView"
android:id
=
"@+id/textViewIndex"
android:layout_height
=
"wrap_content"
android:layout_width
=
"fill_parent"
android:layout_weight
=
"3"
android:textColor
=
"@color/col_black"
android:textSize
=
"14dip"
android:gravity
=
"right|center"
></
TextView
>
<
TextView
android:layout_marginLeft
=
"15dip"
android:layout_marginRight
=
"30dip"
android:text
=
"TextView"
android:id
=
"@+id/textViewValue"
android:layout_height
=
"wrap_content"
android:layout_width
=
"fill_parent"
android:layout_weight
=
"2"
android:textColor
=
"@color/col_blue"
android:textSize
=
"14dip"
android:gravity
=
"left|center"
></
TextView
>
</
LinearLayout
>
整体布局:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<
ScrollView
android:layout_height
=
"wrap_content"
android:layout_width
=
"fill_parent"
android:id
=
"@+id/scrollViewView"
android:layout_above
=
"@+id/relativeLayoutButton"
android:layout_below
=
"@+id/linearLayoutTitle"
>
<
LinearLayout
android:layout_height
=
"wrap_content"
android:layout_width
=
"fill_parent"
android:id
=
"@+id/relativeLayout2"
android:gravity
=
"left"
android:layout_marginTop
=
"60dip"
android:orientation
=
"vertical"
>
<
TextTextItemView
android:id
=
"@+id/itemviewCustid"
android:layout_height
=
"wrap_content"
android:layout_width
=
"fill_parent"
/>
<
TextTextItemView
android:layout_height
=
"wrap_content"
android:layout_width
=
"fill_parent"
android:id
=
"@+id/itemviewItemname"
/>
<
TextTextItemView
android:layout_height
=
"wrap_content"
android:layout_width
=
"fill_parent"
android:id
=
"@+id/itemviewReqcount"
/>
<
TextTextItemView
android:layout_height
=
"wrap_content"
android:layout_width
=
"fill_parent"
android:id
=
"@+id/itemviewOrdercount"
/>
<
TextTextItemView
android:layout_height
=
"wrap_content"
android:layout_width
=
"fill_parent"
android:id
=
"@+id/itemviewUnitprice"
/>
<
TextTextItemView
android:layout_height
=
"wrap_content"
android:layout_width
=
"fill_parent"
android:id
=
"@+id/itemviewPrice"
/>
</
LinearLayout
>
</
ScrollView
>
这个方法的优点在于,方便让每一行都统一,如果需要修改,只需要修改这个控件里面的布局。
方法2:用listView来填充,把每一条作为一个listView的item;
写这么一个Item布局:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<
LinearLayout
xmlns:android
=
"http://schemas.android.com/apk/res/android"
android:layout_width
=
"fill_parent"
android:layout_height
=
"fill_parent"
android:orientation
=
"horizontal"
android:layout_marginTop
=
"3dip"
android:layout_marginBottom
=
"3dip"
>
<
TextView
android:layout_marginLeft
=
"15dip"
android:text
=
"TextView"
android:id
=
"@+id/textViewIndex"
android:layout_height
=
"wrap_content"
android:layout_width
=
"fill_parent"
android:layout_weight
=
"3"
android:textColor
=
"@color/col_black"
android:textSize
=
"14dip"
android:gravity
=
"right|center"
></
TextView
>
<
TextView
android:layout_marginLeft
=
"15dip"
android:layout_marginRight
=
"30dip"
android:text
=
"TextView"
android:id
=
"@+id/textViewValue"
android:layout_height
=
"wrap_content"
android:layout_width
=
"fill_parent"
android:layout_weight
=
"2"
android:textColor
=
"@color/col_blue"
android:textSize
=
"14dip"
android:gravity
=
"left|center"
></
TextView
>
</
LinearLayout
>
然后主界面一个listView:
1
2
3
4
5
6
7
8
9
10
<
SPAN
style
=
"FONT-SIZE: 13px"
><
LinearLayout
xmlns:android
=
"http://schemas.android.com/apk/res/android"
android:layout_width
=
"fill_parent"
android:layout_height
=
"fill_parent"
android:orientation
=
"horizontal"
android:layout_marginTop
=
"3dip"
android:layout_marginBottom
=
"3dip"
>
<
ListView
android:layout_marginLeft
=
"15dip"
android:text
=
"TextView"
android:id
=
"@+id/textViewIndex"
android:layout_height
=
"wrap_content"
android:layout_width
=
"fill_parent"
android:layout_weight
=
"3"
android:textColor
=
"@color/col_black"
android:textSize
=
"14dip"
android:gravity
=
"right|center"
></
ListView
>
</
LinearLayout
></
SPAN
>
然后代码里面建立一个list,把每一条的数据放进去:
1
2
<SPAN style=
"FONT-SIZE: 13px"
>ArrayList<HashMap<string , string>> mDetail=
new
ArrayList<HashMap<string , string>>;
mDetail.add(
new
HashMap(
"abc"
,
"abc"
));</SPAN>
这个方法的优点同上,而且还可以少定义XML,因为上面那个需要写一个一个的自定义控件,这个一个listView搞定。
但是缺点在于代码里面要一直add,还要写adapter,而且listView的显示效果不是很好控制。
方法3:最原始的,一个一个摆控件
这个方法的优点在于他最灵活,想怎么弄怎么弄
缺点在于改起来实在太麻烦。。。。。
- android 详细信息显示界面的思路
- android 详细信息显示界面的思路
- Android中设置只有程序第一次运行才显示的界面实现思路
- 检索Android的图片库并显示图片详细信息
- 显示文件详细信息的命令
- 显示详细信息
- Android进阶2之检索Android的图片库并显示图片详细信息
- android 自己的思路写的订单管理界面
- 获取dataview显示的文件的详细信息
- 关于DataView显示数据库详细信息的问题
- 用ps命令显示进程的详细信息
- GNU autotools 显示编译的详细信息
- 我的电脑 默认 显示 详细信息
- ARM架构显示寄存器的详细信息
- 商品详情页显示商品的详细信息
- .做一个登陆的界面,当用户输入正确的用户名和密码后,显示登陆成功,并且显示改用户的详细信息。(sqldatasource)
- android 输入法界面显示的开关
- android 启动界面广告的显示
- android 2.3 频率管理
- 如何使用java synchronized进行线程同步
- Linux操作系统下Sudo命令的使用方法说明
- Android实战经验之Incude便签
- 务虚
- android 详细信息显示界面的思路
- 如何写Vim脚本(一)
- 要开始学c语言了
- Linux Sudo的使用
- VB.Net Winform程序的简单打包和部署--<机房收费系统>
- swjtu oj 1579 加号问题
- android开发常用命令
- C语言经典算法:如何较快的分解质因数
- android 2.3 电源管理