你好,游客 登录 注册 搜索
背景:
阅读新闻

Android开发实践:多级列表的封装与应用

[日期:2013-09-25] 来源:Linux社区  作者:ticktick [字体:大 中 小]

4.  相关的xml文件

(1) grouplist_child.xml 文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:Android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">
                                                                                                                                     
    <TextView
        android:id="@+id/GroupListChild"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#FFFF0000"
        android:layout_margin="10dp"
        android:layout_centerInParent="true"/>
                                                                                                                                     
</RelativeLayout>

(2) grouplist_parent.xml 文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">
                                                                                                           
    <TextView
        android:id="@+id/GroupListParent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@android:color/black"
        android:textStyle="bold"
        android:layout_margin="10dp"
        android:layout_centerInParent="true"/>
                                                                                                           
</RelativeLayout>

5.  总结

本文给出了Android多级列表的封装与应用的示例,个人感觉这样封装的设计可扩展性挺好的,特别是两个特点:1. 屏蔽了一级标题和二级标题的差异,统一接口;2. 将layout均放到Adapter的Item的类中去实现,让Adapter与layout脱离耦合。这两种设计思路,相信在以后的软件设计中也会经常用到。整个工程的代码在附件中,代码结构还算清楚,就不用过多解释啦。

linux
相关资讯       Android开发 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款