设为首页 加入收藏

TOP

ListFragment的使用(三)
2017-10-13 10:35:47 】 浏览:7452
Tags:ListFragment 使用
g, Object>>(); Map<String, Object> map = new HashMap<String, Object>(); map.put("title", "课程名称"); map.put("info", tname[p]); list.add(map); map = new HashMap<String, Object>(); map.put("title", "教师姓名"); map.put("info", ttitle[p]); list.add(map); map = new HashMap<String, Object>(); map.put("title", "学时"); map.put("info", ttime[p]); list.add(map); map = new HashMap<String, Object>(); map.put("title", "图片"); map.put("picture", pic[p]); list.add(map); return list; } }

布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <!-- ListFragment对应的android:id值固定为"@id/android:list" -->
    <ListView
        android:id="@id/android:list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:drawSelectorOnTop="false"
        />

</LinearLayout>

行布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView android:id="@+id/text0"
        android:textSize="12sp"
        android:textStyle="bold"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <TextView android:id="@+id/text1"
        android:textSize="12sp"
        android:textStyle="bold"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <TextView android:id="@+id/text2"
        android:textSize="24sp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <ImageView
        android:id="@+id/picture"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp" />

</LinearLayout>

最重要的方法是,当点击左边ListFragment的某一行时,取得改行的position,然后根据Tag找到右边的ListFragment,并调用flushData()方法,使右边的ListFragment刷新数据。

3. 运行结果

 

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇浅析Dagger2的使用 下一篇Android开发5大布局方式详解

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目