android 详细信息显示界面的思路
来源:互联网 发布:手机淘宝客服在哪 编辑:程序博客网 时间:2024/05/23 12:14
开发的时候,有时候会遇到类似下面这种,需要显示大量数据的界面:
控件量很大,需要定义很多的textView 之类的东西,还需要用relativeLayout 来控制什么左对齐右对齐,这里有提供2种相对简便的方法。
方法1:自定义一个控件,此控件包含一横条的布局;
定义一个叫TextTextView的控件:
<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>
整体布局:
<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"><TextTextItemViewandroid:id="@+id/itemviewCustid" android:layout_height="wrap_content"android:layout_width="fill_parent" /><TextTextItemViewandroid:layout_height="wrap_content" android:layout_width="fill_parent"android:id="@+id/itemviewItemname" /><TextTextItemViewandroid:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/itemviewReqcount"/><TextTextItemViewandroid:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/itemviewOrdercount"/><TextTextItemViewandroid:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/itemviewUnitprice"/><TextTextItemViewandroid:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/itemviewPrice"/></LinearLayout></ScrollView>
这个方法的优点在于,方便让每一行都统一,如果需要修改,只需要修改这个控件里面的布局。
方法2:用listView来填充,把每一条作为一个listView的item;
写这么一个Item布局:
<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:
<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>
然后代码里面建立一个list,把每一条的数据放进去:
ArrayList<HashMap<string , string>> mDetail= new ArrayList<HashMap<string , string>>;mDetail.add(new HashMap("abc","abc"));
这个方法的优点同上,而且还可以少定义XML,因为上面那个需要写一个一个的自定义控件,这个一个listView搞定。
但是缺点在于代码里面要一直add,还要写adapter,而且listView的显示效果不是很好控制。
方法3:最原始的,一个一个摆控件
这个方法的优点在于他最灵活,想怎么弄怎么弄
缺点在于改起来实在太麻烦。。。。。
- android 详细信息显示界面的思路
- android 详细信息显示界面的思路
- Android中设置只有程序第一次运行才显示的界面实现思路
- 检索Android的图片库并显示图片详细信息
- 显示文件详细信息的命令
- 显示详细信息
- Android进阶2之检索Android的图片库并显示图片详细信息
- android 自己的思路写的订单管理界面
- 获取dataview显示的文件的详细信息
- 关于DataView显示数据库详细信息的问题
- 用ps命令显示进程的详细信息
- GNU autotools 显示编译的详细信息
- 我的电脑 默认 显示 详细信息
- ARM架构显示寄存器的详细信息
- 商品详情页显示商品的详细信息
- .做一个登陆的界面,当用户输入正确的用户名和密码后,显示登陆成功,并且显示改用户的详细信息。(sqldatasource)
- android 输入法界面显示的开关
- android 启动界面广告的显示
- 在ubuntu 11.10上面安装svn服务器的过程
- 开源计算机图形学社区
- ListView的动态加载效果
- 比较page、request、session、application的使用范围
- Linux线程经验
- android 详细信息显示界面的思路
- Nginx学习
- 自定义Lamda表达式作为筛选条件
- Struts2 jdbc 增删改查
- poj1338
- 着色语言基础介绍
- UltraEdit 的复制、粘贴功能,其他几个使用小技巧
- windows azure试用感受2
- javascript 编程注意事项