ListView嵌套ListView实现论坛评论效果

本文介绍如何在Android中通过ListView嵌套ListView来实现论坛评论的效果,包括点击评论按钮弹出输入框、内层ListView的显示以及TextView的换行策略。详细讲解了相关XML文件的布局设计,如theme_detail,以及Adapter的使用,如ListStoreAdapter和ListChildStoreAdapter,重点讨论了android:descendantFocusability属性的设置,以达到不同的焦点控制效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">        开发过程中,根据需求需要做一个类似于百度贴吧APP中,论坛评论回复的效果。这个问题其实挺愁人的,它牵扯到如何是多级嵌套的listview都能正常显示。中间牵扯到的问题是:</span>

(1)、点击评论按钮,如何弹出软键盘评论框

(2)、ListView如何嵌套ListView显示

(3)、显示不开的TextView如何换到顶行显示,而不是简单的换行显示。

话不多说,先上图:


下面介绍实现步骤:

一、搭建相关XML文件

(1)、theme_detail

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginLeft="10dip"
    android:layout_marginRight="10dip"
    android:layout_marginTop="10dip"
    android:background="@color/white"
    android:orientation="vertical" >

    <RelativeLayout
        android:id="@+id/isbuy_theme_detail_layout00"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/isbuy_theme_detail_layout00_image01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/isbuy_theme_detail_layout00_image03"
            android:layout_alignParentLeft="true"
            android:src="@drawable/isbuy_leftback" />

        <TextView
            android:id="@+id/isbuy_theme_detail_layout00_text01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/isbuy_theme_detail_layout00_image01"
            android:layout_marginLeft="3dip"
            android:layout_toRightOf="@+id/isbuy_theme_detail_layout00_image01"
            android:text="@string/isbuy_theme_detail_title"
            android:textColor="@color/black"
            android:textSize="20sp" />

        <ImageView
            android:id="@+id/isbuy_theme_detail_layout00_image03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:src="@drawable/isbuy_search_share" />

        <ImageView
            android:id="@+id/isbuy_theme_detail_layout00_image02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dip"
            android:layout_toLeftOf="@+id/isbuy_theme_detail_layout00_image03"
            android:src="@drawable/isbuy_top_02" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/isbuy_theme_detail_layout01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/isbuy_theme_detail_layout00"
        android:layout_marginLeft="10dip" >

        <RelativeLayout
            android:id="@+id/isbuy_theme_detail_layout01_Image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@color/white" >

            <ProgressBar
                android:id="@+id/isbuy_theme_detail_layout01_Image_progressBar"
                style="?android:attr/progressBarStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true" />

            <com.west.aipuli.wheretobuy.unit.CPRoundImageView
                android:id="@+id/isbuy_theme_detail_layout01_Image_itemsIcon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:src="@drawable/person_image01" >
            </com.west.aipuli.wheretobuy.unit.CPRoundImageView>
        </RelativeLayout>

        <TextView
            android:id="@+id/isbuy_theme_detail_layout01_text01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:layout_marginTop="5dip"
            android:layout_toRightOf="@+id/isbuy_theme_detail_layout01_Image"
            android:text="@string/search_build_detail_02_name"
            android:textColor="@color/black"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/isbuy_theme_detail_layout01_text02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/isbuy_theme_detail_layout01_text01"
            android:layout_below="@+id/isbuy_theme_detail_layout01_text01"
            android:layout_marginTop="5dip"
            android:layout_toRightOf="@+id/isbuy_theme_detail_layout01_Image"
            android:text="@string/search_build_detail_02_date"
            android:textColor="@color/text_color"
            android:textSize="16sp" />
    </RelativeLayout>

    <TextView
        android:id="@+id/isbuy_theme_detail_text01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/isbuy_theme_detail_layout01"
        android:layout_marginLeft="10dip"
        android:layout_marginTop="5dip"
        android:text="@string/isbuy_search_list02_title"
        android:textColor="@color/black"
        android:textSize="20sp" />

    <TextView
        android:id="@+id/isbuy_theme_detail_text02"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/isbuy_theme_detail_text01"
        android:layout_marginLeft="10dip"
        android:layout_marginTop="5dip"
        android:background="@drawable/isbuy_write_shap"
        android:text="@string/isbuy_search_write_lable"
        android:textColor="@color/white"
        android:textSize="16sp" />

    <View
        android:id="@+id/isbuy_theme_detail_divder1"
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:layout_below="@+id/isbuy_theme_detail_text02"
        android:layout_marginTop="5dip"
        android:background="?android:attr/listDivider" />

    <RelativeLayout
        android:id="@+id/isbuy_theme_detail_layout05"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/isbuy_theme_detail_divder1"
        android:layout_marginLeft="10dip"
        android:layout_marginTop="5dip" >

        <TextView
            android:id="@+id/isbuy_theme_detail_text03"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/isbuy_theme_detail_content"
            android:textColor="@color/black"
            android:textSize="16sp" />

        <TextView
            android:id="@+id/isbuy_theme_detail_anim"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/isbuy_theme_detail_text03"
            android:layout_marginRight="70dip"
            android:layout_marginTop="5dip"
            android:text="+1"
            android:textColor="@color/orange"
            android:textSize="14sp"
            android:visibility="gone" />

        <TextView
            android:id="@+id/isbuy_theme_detail_anim_gone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/isbuy_theme_detail_text03"
            android:layout_marginRight="70dip"
            android:layout_marginTop="5dip"
            android:text="-1"
            android:textColor="@color/orange"
            android:textSize="14sp"
            android:visibility="gone" />

        <RelativeLayout
            android:id="@+id/isbuy_theme_detail_layout02"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/isbuy_theme_detail_text03"
            android:layout_marginRight="10dip"
            android:layout_marginTop="20dip" >
            
            <ImageView
                android:id="@+id/isbuy_theme_detail_layout02_replay"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/isbuy_up" >
            </ImageView>
            
            <ImageView
                android:id="@+id/isbuy_theme_detail_layout02_up"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="90dip"
                android:src="@drawable/isbuy_up" >
            </ImageView>

            <ImageView
                android:id="@+id/isbuy_theme_detail_layout02_up_gone"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="90dip"
                android:src="@drawable/isbuy_up_push"
                android:visibility="gone" >
            </ImageView>

            <TextView
                android:id="@+id/isbuy_theme_detail_layout02_count"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="40dip"
                android:layout_marginTop="5dip"
                android:text="@string/person_store_talk_count"
                android:textColor="@color/black"
                android:textSize="16sp" >
            </TextView>

            <ImageView
                android:id="@+id/isbuy_theme_detail_layout02_down"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="5dip"
                android:src="@drawable/isbuy_down" >
            </ImageView>

            <ImageView
                android:id="@+id/isbuy_theme_detail_layout02_down_gone"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="5dip"
                android:src="@drawable/isbuy_down_push"
                android:visibility="gone" >
            </ImageView>
        </RelativeLayout>
    </RelativeLayout>

    <View
        android:id="@+id/divder01"
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:layout_below="@+id/isbuy_theme_detail_layout05"
        android:background="@color/light_gray" />

    <com.west.aipuli.wheretobuy.listview.XListView
        android:id="@+id/isbuy_theme_detail_xListView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/isbuy_theme_detail_layout03"
        android:layout_below="@+id/divder01"
        android:cacheColorHint="#00000000"
        android:divider="@drawable/list_divider"
        android:dividerHeight="1dip" >
    </com.west.aipuli.wheretobuy.listview.XListView>
    
    <RelativeLayout
        android:id="@+id/isbuy_theme_detail_layout03"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="5dip"
        android:layout_marginTop="5dip" 
        android:visibility="gone">

        <EditText
            android:id="@+id/isbuy_theme_detail_layout03_edit01"
            android:layout_width="280dip"
            android:layout_height="40dip"
            android:background="@drawable/search_main"
            android:hint="@string/person_store_talk_replay"
            android:textColor="@color/text_color"
            android:textSize="16sp" />

        <Button
            android:id="@+id/isbuy_theme_detail_layout03_btn01"
            android:layout_width="70dip"
            android:layout_height="40dip"
            android:layout_marginRight="5dip"
            android:layout_alignParentRight="true"
            android:background="@drawable/aniublank"
            android:text="@string/person_store_talk_replay_title"
            android:textColor="@color/white"
            android:textSize="16sp" />
    </RelativeLayout>

</RelativeLayout>
(2)、theme_detail_list.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/white"
    android:descendantFocusability="beforeDescendants" >

    <RelativeLayout
        android:id="@+id/isbuy_theme_detail_list_layout01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <RelativeLayout
            android:id="@+id/isbuy_theme_detail_list_layout01_Image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@color/white" >

            <ProgressBar
                android:id="@+id/isbuy_theme_detail_list_layout01_Image_progressBar"
                style="?android:attr/progressBarStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true" />

            <com.west.aipuli.wheretobuy.unit.CPRoundImageView
                android:id="@+id/isbuy_theme_detail_list_layout01_Image_itemsIcon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:src="@drawable/person_image01" >
            </com.west.aipuli.wheretobuy.unit.CPRoundImageView>
        </RelativeLayout>

        <TextView
            android:id="@+id/isbuy_theme_detail_list_layout01_text01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:layout_marginTop="5dip"
            android:layout_toRightOf="@+id/isbuy_theme_detail_list_layout01_Image"
            android:text="@string/search_build_detail_02_name"
            android:textColor="@color/black"
            android:textSize="16sp" />

        <TextView
            android:id="@+id/isbuy_theme_detail_list_layout01_text02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/isbuy_theme_detail_list_layout01_text01"
            android:layout_below="@+id/isbuy_theme_detail_list_layout01_text01"
            android:layout_marginTop="5dip"
            android:layout_toRightOf="@+id/isbuy_theme_detail_list_layout01_Image"
            android:text="@string/search_build_detail_02_date"
            android:textColor="@color/text_color"
            android:textSize="14sp" />

        <RelativeLayout
            android:id="@+id/isbuy_theme_detail_list_layout01_01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignTop="@+id/isbuy_theme_detail_list_layout01_text01"
            android:layout_marginRight="10dip"
            android:layout_marginTop="5dip" >

            <ImageView
                android:id="@+id/isbuy_theme_detail_list_layout01_image02"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/isbuy_theme_detail_list_layout01_text03"
                android:layout_marginRight="3dip"
                android:layout_toLeftOf="@+id/isbuy_theme_detail_list_layout01_text03"
                android:src="@drawable/isbuy_theme_detail_pay" />

            <TextView
                android:id="@+id/isbuy_theme_detail_list_layout01_text03"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:text="@string/isbuy_theme_detail_ping_replay_title"
                android:textColor="@color/text_color"
                android:textSize="14sp" />
        </RelativeLayout>
    </RelativeLayout>

    <View
        android:id="@+id/isbuy_theme_detail_list_divder1"
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:layout_below="@+id/isbuy_theme_detail_list_layout01"
        android:layout_marginLeft="5dip"
        android:layout_marginRight="5dip"
        android:layout_marginTop="5dip"
        android:background="?android:attr/listDivider" />

    <RelativeLayout
        android:id="@+id/isbuy_theme_detail_list_layout02"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/isbuy_theme_detail_list_divder1"
        android:layout_marginLeft="10dip"
        android:layout_marginTop="5dip" >

        <TextView
            android:id="@+id/isbuy_theme_detail_list_layout02_text01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/isbuy_theme_detail_ping_replay_content"
            android:textColor="@color/black"
            android:textSize="16sp" />

        <TextView
            android:id="@+id/isbuy_theme_detail_list_layout02_text02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/isbuy_theme_detail_list_layout02_text01"
            android:layout_marginTop="15dip"
            android:text="@string/isbuy_theme_detail_ping_replay_count"
            android:textColor="@color/text_color"
            android:textSize="14sp" />

        <TextView
            android:id="@+id/isbuy_theme_detail_list_layout02_anim"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginRight="35dip"
            android:layout_marginTop="10dip"
            android:text="+1"
            android:textColor="@color/orange"
            android:textSize="14sp"
            android:visibility="gone" />

        <TextView
            android:id="@+id/isbuy_theme_detail_list_layout02_anim_gone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginRight="35dip"
            android:layout_marginTop="10dip"
            android:text="-1"
            android:textColor="@color/orange"
            android:textSize="14sp"
            android:visibility="gone" />

        <RelativeLayout
            android:id="@+id/isbuy_theme_detail_list_layout02_01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/isbuy_theme_detail_list_layout02_text02"
            android:layout_alignParentRight="true" >

            <ImageView
                android:id="@+id/isbuy_theme_detail_list_layout02_01_up"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="58dip"
                android:src="@drawable/isbuy_search_up" >
            </ImageView>

            <ImageView
                android:id="@+id/isbuy_theme_detail_list_layout02_01_up_gone"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="58dip"
                android:src="@drawable/isbuy_search_up_push"
                android:visibility="gone" >
            </ImageView>

            <TextView
                android:id="@+id/isbuy_theme_detail_list_layout02_01_count"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="30dip"
                android:text="@string/person_store_talk_count"
                android:textColor="@color/black"
                android:textSize="14sp" >
            </TextView>

            <ImageView
                android:id="@+id/isbuy_theme_detail_list_layout02_01_down"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="5dip"
                android:src="@drawable/isbuy_search_down" >
            </ImageView>

            <ImageView
                android:id="@+id/isbuy_theme_detail_list_layout02_01_down_gone"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="5dip"
                android:src="@drawable/isbuy_search_down_push"
                android:visibility="gone" >
            </ImageView>
        </RelativeLayout>
    </RelativeLayout>

    <View
        android:id="@+id/isbuy_theme_detail_list_divder2"
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:layout_below="@+id/isbuy_theme_detail_list_layout02"
        android:layout_marginLeft="5dip"
        android:layout_marginRight="5dip"
        android:layout_marginTop="5dip"
        android:background="?android:attr/listDivider" />

    <com.west.aipuli.wheretobuy.listview.XListView
        android:id="@+id/isbuy_theme_detail_list_xListView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/isbuy_theme_detail_list_divder2"
        android:divider="@null"
        android:listSelector="#00000000" 
        android:layout_marginLeft="10dip"
        android:layout_marginRight="5dip"
        android:layout_marginTop="5dip"
        android:cacheColorHint="#00000000" >
    </com.west.aipuli.wheretobuy.listview.XListView>

    <LinearLayout
        android:id="@+id/isbuy_theme_detail_list_layout03"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/isbuy_theme_detail_list_xListView"
        android:layout_centerInParent="true"
        android:layout_marginTop="5dip"
        android:orientation="horizontal"
        android:visibility="gone" >

        <TextView
            android:id="@+id/isbuy_theme_detail_list_layout03_text01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/isbuy_theme_detail_ping_replay_get"
            android:textColor="@color/text_color"
            android:textSize="14sp" />

        <TextView
            android:id="@+id/isbuy_theme_detail_list_layout03_text02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/isbuy_theme_detail_ping_replay_get01"
            android:textColor="@color/orange"
            android:textSize="14sp" />

        <TextView
            android:id="@+id/isbuy_theme_detail_list_layout03_text03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/isbuy_theme_detail_ping_replay_get02"
            android:textColor="@color/text_color"
            android:textSize="14sp" />
    </LinearLayout>

</RelativeLayout>
(3)、theme_detail_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/isbuy_theme_detail_list_layout03"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_marginTop="10dip"
    android:layout_marginBottom="10dip"
    android:descendantFocusability="afterDescendants" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <TextView
            android:id="@+id/isbuy_theme_detail_list_layout03_text01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/isbuy_theme_detail_ping_replay_from"
            android:textColor="@color/orange"
            android:textSize="14sp" />
        <TextView
            android:id="@+id/isbuy_theme_detail_list_layout03_text01_deafult"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/isbuy_theme_detail_ping_replay_from_default"
            android:textColor="@color/text_color"
            android:textSize="14sp" />
        <TextView
            android:id="@+id/isbuy_theme_detail_list_layout03_text02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/isbuy_theme_detail_ping_replay_to"
            android:textColor="@color/orange"
            android:textSize="14sp" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=":"
            android:textColor="@color/text_color"
            android:textSize="14sp" />
        <TextView
            android:id="@+id/isbuy_theme_detail_list_layout03_text03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/isbuy_theme_detail_ping_replay_content2"
            android:textColor="@color/text_color"
            android:textSize="14sp" />
    </LinearLayout>

    <TextView
        android:id="@+id/arround_text01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/text_color"
        android:textSize="14sp"
        android:visibility="gone" />

</LinearLayout>
二、声明相关实体类,以及相关Adapter

本文章的重点是Xml文件的布局,以及Adapter的声明。在此对于实体类就不多做介绍了,主要介绍一下相关adapter

(1)、声明实体类:ListStore,ListChildStore

(2)、声明Adapter:ListStoreAdapter,ListChildStoreAdapter

ListStoreAdapter关键代码:

public class <span style="font-size: 18px;">ListStoreAdapter</span>extends BaseAdapter {

	private Context mContext;
	// 列展现的数据
	List<<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-size: 18px;">ListStore</span></span>> mList = null;
	// 图片下载器
	private AbImageLoader mAbImageLoader = null;
	private ListChildStoreAdapteradapter = null;
	private List<<span style="font-size: 18px;"><span style="font-size: 18px;">ListChildStore</span></span>> list = null;

	// 构造方法
	public <span style="font-size: 18px;">ListStoreAdapter</span>(Context context,
			List<<span style="font-size: 18px;">ListStore</span>> list) {
		mContext = context;
		mList = list;
		// 图片下载器
		mAbImageLoader = new AbImageLoader(mContext);
		mAbImageLoader.setMaxWidth(200);
		mAbImageLoader.setMaxHeight(200);
		mAbImageLoader.setLoadingImage(R.drawable.image_loading);
		mAbImageLoader.setErrorImage(R.drawable.image_error);
		mAbImageLoader.setEmptyImage(R.drawable.image_empty);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		if (mList == null) {
			return 0;
		}
		return mList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		final ViewHolder holder;
		if (convertView == null) {
			// 使用自定义的list_items作为Layout
			convertView = LayoutInflater.from(mContext).inflate(R.layout.isbuy_theme_detail_list, parent, false);
			// 使用减少findView的次数
			holder = new ViewHolder();
			holder.isbuy_theme_detail_list_layout01_Image_itemsIcon = (ImageView) convertView.findViewById(R.id.isbuy_theme_detail_list_layout01_Image_itemsIcon);
			holder.isbuy_theme_detail_list_layout01_text01 = (TextView) convertView.findViewById(R.id.isbuy_theme_detail_list_layout01_text01);
			holder.isbuy_theme_detail_list_layout01_text02 = (TextView) convertView.findViewById(R.id.isbuy_theme_detail_list_layout01_text02);
			
			holder.isbuy_theme_detail_list_layout02_text01 = (TextView) convertView.findViewById(R.id.isbuy_theme_detail_list_layout02_text01);
			holder.isbuy_theme_detail_list_layout02_text02 = (TextView) convertView.findViewById(R.id.isbuy_theme_detail_list_layout02_text02);
			holder.isbuy_theme_detail_list_layout02_anim = (TextView) convertView.findViewById(R.id.isbuy_theme_detail_list_layout02_anim);
			holder.isbuy_theme_detail_list_layout02_anim_gone = (TextView) convertView.findViewById(R.id.isbuy_theme_detail_list_layout02_anim_gone);

			holder.isbuy_theme_detail_list_layout02_01_up = (ImageView) convertView.findViewById(R.id.isbuy_theme_detail_list_layout02_01_up);
			holder.isbuy_theme_detail_list_layout02_01_up_gone = (ImageView) convertView.findViewById(R.id.isbuy_theme_detail_list_layout02_01_up_gone);
			holder.isbuy_theme_detail_list_layout02_01_count = (TextView) convertView.findViewById(R.id.isbuy_theme_detail_list_layout02_01_count);
			holder.isbuy_theme_detail_list_layout02_01_down = (ImageView) convertView.findViewById(R.id.isbuy_theme_detail_list_layout02_01_down);
			holder.isbuy_theme_detail_list_layout02_01_down_gone = (ImageView) convertView.findViewById(R.id.isbuy_theme_detail_list_layout02_01_down_gone);
			holder.isbuy_theme_detail_list_xListView = (XListView) convertView.findViewById(R.id.isbuy_theme_detail_list_xListView);
			holder.isbuy_theme_detail_list_xListView.setPullRefreshEnable(false);
			holder.isbuy_theme_detail_list_xListView.setFocusable(false);
			holder.isbuy_theme_detail_list_xListView.setFocusableInTouchMode(false);
			
			holder.isbuy_theme_detail_list_layout03=(LinearLayout)convertView.findViewById(R.id.isbuy_theme_detail_list_layout03);
			holder.isbuy_theme_detail_list_layout03_text02 = (TextView) convertView.findViewById(R.id.isbuy_theme_detail_list_layout03_text02);
			// 设置标记
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		// 获得该行数据
		IsBuyThemeDetailReplayStore Store = mList.get(position);
		// 设置数据到View
		String imageUrl = Store.getImageUrl();
		// 设置加载中的View
		mAbImageLoader.setLoadingView(convertView.findViewById(R.id.isbuy_theme_detail_list_layout01_Image_progressBar));
		// 图片的下载
		// mAbImageLoader.display(holder.isbuy_theme_detail_list_layout01_Image_itemsIcon,imageUrl);
		// 设置显示的其他属性
		holder.isbuy_theme_detail_list_layout01_text01.setText(Store.getReplayUserName());
		holder.isbuy_theme_detail_list_layout01_text02.setText(Store.getReplayDate());
		holder.isbuy_theme_detail_list_layout02_text01.setText(Store.getThemeReplayContent());
		holder.isbuy_theme_detail_list_layout02_text02.setText(Store.getThemeReplayBuilder());
		holder.isbuy_theme_detail_list_layout02_01_count.setText(Store.getThemeReplayCount());

		// 设置点击上下按钮动画事件
		holder.isbuy_theme_detail_list_layout02_01_up
				.setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						int count = Integer.valueOf(holder.isbuy_theme_detail_list_layout02_01_count.getText().toString());
						holder.isbuy_theme_detail_list_layout02_01_up.setVisibility(View.GONE);
						holder.isbuy_theme_detail_list_layout02_01_up_gone.setVisibility(View.VISIBLE);
						holder.isbuy_theme_detail_list_layout02_01_down.setVisibility(View.VISIBLE);
						holder.isbuy_theme_detail_list_layout02_01_down_gone.setVisibility(View.GONE);

						holder.isbuy_theme_detail_list_layout02_anim.setVisibility(View.VISIBLE);
						holder.isbuy_theme_detail_list_layout02_01_count.setText(String.valueOf(count + 1));
						holder.isbuy_theme_detail_list_layout02_01_up
								.postDelayed(new Runnable() {
									@Override
									public void run() {
										// TODO Auto-generated method stub
										holder.isbuy_theme_detail_list_layout02_anim.setVisibility(View.GONE);
									}
								}, 1000);
						// 向后台发送相应事件

					}
				});
		holder.isbuy_theme_detail_list_layout02_01_down
				.setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						int count = Integer.valueOf(holder.isbuy_theme_detail_list_layout02_01_count.getText().toString());
						holder.isbuy_theme_detail_list_layout02_01_down.setVisibility(View.GONE);
						holder.isbuy_theme_detail_list_layout02_01_down_gone.setVisibility(View.VISIBLE);
						holder.isbuy_theme_detail_list_layout02_01_up.setVisibility(View.VISIBLE);
						holder.isbuy_theme_detail_list_layout02_01_up_gone.setVisibility(View.GONE);

						holder.isbuy_theme_detail_list_layout02_anim_gone.setVisibility(View.VISIBLE);
						holder.isbuy_theme_detail_list_layout02_01_count.setText(String.valueOf(count - 1));
						holder.isbuy_theme_detail_list_layout02_01_down.postDelayed(new Runnable() {
									@Override
									public void run() {
										// TODO Auto-generated method stub
										holder.isbuy_theme_detail_list_layout02_anim_gone.setVisibility(View.GONE);
									}
								}, 1000);
					}
				});
	
		// 获得二级回复对象,加载二级列表到界面中
		list = new ArrayList<IsBuyThemeDetailReplayToReplayStore>();
		Set<IsBuyThemeDetailReplayToReplayStore> storeChild = Store.getReplayStore();
		final int size = storeChild.size();
		//当前页面只显示两条,多余的信息通过点击查看更多跳转新页面进行查看
		int floor = 0;
		int totalfoor = 0;
		int i = 0;
		if(size>2){
			holder.isbuy_theme_detail_list_layout03.setVisibility(View.VISIBLE);
			holder.isbuy_theme_detail_list_layout03_text02.setText(String.valueOf(size-2));
		}else{
			holder.isbuy_theme_detail_list_layout03.setVisibility(View.GONE);
		}
		for (IsBuyThemeDetailReplayToReplayStore ob : storeChild) {
			int totalLength = ob.getUserName01().length()+ ob.getUserName02().length()+ ob.getToReplayContent().length();
			// 先只显示两条
			if (i < 2) {
				floor = floor + totalLength / 25 + 1;
			}
			totalfoor = totalfoor + totalLength / 25 + 1;
			i++;
			list.add(ob);
		}
		adapter = new <span style="font-size: 18px;">ListChildStoreAdapter</span>(mContext, list);
		holder.isbuy_theme_detail_list_xListView.setAdapter(adapter);
		ListHaveListUtility.setListViewHeightBasedOnChildren(holder.isbuy_theme_detail_list_xListView, floor);
		//点击显示更多事件
		holder.isbuy_theme_detail_list_layout03.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent=new Intent(mContext,IsBuyThemeDetailListActivity.class);
				mContext.startActivity(intent);
			}
		});
		return convertView;
	}

	/**
	 * ViewHolder类
	 */
	static class ViewHolder {
		ImageView isbuy_theme_detail_list_layout01_Image_itemsIcon;
		TextView isbuy_theme_detail_list_layout01_text01;
		TextView isbuy_theme_detail_list_layout01_text02;
		
		TextView isbuy_theme_detail_list_layout02_text01;
		TextView isbuy_theme_detail_list_layout02_text02;
		TextView isbuy_theme_detail_list_layout02_anim;
		TextView isbuy_theme_detail_list_layout02_anim_gone;

		ImageView isbuy_theme_detail_list_layout02_01_up;
		ImageView isbuy_theme_detail_list_layout02_01_up_gone;
		TextView  isbuy_theme_detail_list_layout02_01_count;
		ImageView isbuy_theme_detail_list_layout02_01_down;
		ImageView isbuy_theme_detail_list_layout02_01_down_gone;
		XListView  isbuy_theme_detail_list_xListView;
        
        LinearLayout isbuy_theme_detail_list_layout03;
		TextView isbuy_theme_detail_list_layout03_text02;

	}

}

ListChildStoreAdapter关键代码:

public class <span style="font-size: 18px;">ListChildStoreAdapter</span>extends BaseAdapter{
	private Context mContext;
	//列展现的数据
	List<<span style="font-size: 18px;">ListChildStore</span>> mList=null;
	//获得父控件的宽度
	int screenWidth = 0;
	int name01Width=0;
	int name02Width=0;
	//构造方法
	public <span style="font-size: 18px;">ListChildStoreAdapter</span>(Context context,List<<span style="font-size: 18px;">ListChildStore</span>> list){
		mContext=context;
		mList=list;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
    	if(mList==null){
    		return 0;
    	}
        return mList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		final ViewHolder holder;
		if(convertView==null){
			//使用自定义的list_items作为Layout
			convertView = LayoutInflater.from(mContext).inflate(R.layout.isbuy_theme_detail_list_list, parent, false);
			//使用减少findView的次数
			holder = new ViewHolder();
			holder.isbuy_theme_detail_list_layout03_text01=(TextView)convertView.findViewById(R.id.isbuy_theme_detail_list_layout03_text01);
			holder.isbuy_theme_detail_list_layout03_text02=(TextView)convertView.findViewById(R.id.isbuy_theme_detail_list_layout03_text02);
			holder.isbuy_theme_detail_list_layout03_text03=(TextView)convertView.findViewById(R.id.isbuy_theme_detail_list_layout03_text03);
			holder.arround_text01=(TextView)convertView.findViewById(R.id.arround_text01);
			//设置标记
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder) convertView.getTag();
		}
		//获得该行数据
		IsBuyThemeDetailReplayToReplayStore themeStore=mList.get(position);
		//格式化显示方式
		screenWidth=FormatStringUnit.getScreenWidth(mContext);
		//格式化字符串
		String name1=themeStore.getUserName01();
		if(name1!=null){
			name1=FormatStringUnit.stringFilter(FormatStringUnit.ToDBC(name1));
		}
		String name2=themeStore.getUserName02();
		if(name2!=null){
			name2=FormatStringUnit.stringFilter(FormatStringUnit.ToDBC(name2));
		}
		//设置显示的其他属性
        holder.isbuy_theme_detail_list_layout03_text01.setText(name1);
        holder.isbuy_theme_detail_list_layout03_text02.setText(name2);
        name01Width=name1.length();
        name02Width=name2.length();
		String content=themeStore.getToReplayContent();
		if(content!=null){
			content=FormatStringUnit.stringFilter(FormatStringUnit.ToDBC(content));
		}
		int contentWidth=content.length();
		int lastWidth=24-name01Width-name02Width;
		holder.arround_text01.setVisibility(View.GONE);
		if(contentWidth>lastWidth){
			 holder.isbuy_theme_detail_list_layout03_text03.setText(content.substring(0, lastWidth-1));
			 holder.arround_text01.setVisibility(View.VISIBLE);
             holder.arround_text01.setText(content.substring(lastWidth));
		}else{
			holder.isbuy_theme_detail_list_layout03_text03.setText(content);
		}
		return convertView;
	}
    /**
	 * ViewHolder类
	 */
	static class ViewHolder {
		TextView isbuy_theme_detail_list_layout03_text01;
		TextView isbuy_theme_detail_list_layout03_text02;
		TextView isbuy_theme_detail_list_layout03_text03;
		TextView arround_text01;
	}
}
(3)activity进行调用

public class IsBuyThemeDetailActivity extends AbActivity implements
		OnClickListener,IXListViewListener,OnItemClickListener{

	private ImageView isbuy_theme_detail_layout00_image01;
	private ImageView isbuy_theme_detail_layout00_image02;
	private ImageView isbuy_theme_detail_layout00_image03;

	private CPRoundImageView isbuy_theme_detail_layout01_Image_itemsIcon;
	private TextView isbuy_theme_detail_layout01_text01;
	private TextView isbuy_theme_detail_layout01_text02;
	private TextView isbuy_theme_detail_text01;
	private TextView isbuy_theme_detail_text02;
	private TextView isbuy_theme_detail_text03;

	private String builderName;
	private ImageView isbuy_theme_detail_layout02_replay;
	private ImageView isbuy_theme_detail_layout02_up;
	private ImageView isbuy_theme_detail_layout02_up_gone;
	private TextView isbuy_theme_detail_anim;
	private TextView isbuy_theme_detail_layout02_count;
	private ImageView isbuy_theme_detail_layout02_down;
	private ImageView isbuy_theme_detail_layout02_down_gone;
	private TextView isbuy_theme_detail_anim_gone;

	private XListView isbuy_theme_detail_xListView;
	private List<IsBuyThemeDetailReplayStore> mList = null;
	private IsBuyThemeDetailReplayListAdapter listAdapter=null;
	private int currentPage = 1;
	private int pageSize = 3;
	private Handler mHandler;
	private Intent intent = null;
	
	private RelativeLayout isbuy_theme_detail_layout03;
    private EditText isbuy_theme_detail_layout03_edit01;
    private Button isbuy_theme_detail_layout03_btn01;
    
    //评论列表内容
    private RelativeLayout isbuy_theme_detail_list_layout01_01;
    private ImageView isbuy_theme_detail_list_layout01_image;
    private TextView isbuy_theme_detail_list_layout01_name;
    private String isbuy_theme_detail_list_layout01_nameId=null;
    private String name;
    private XListView listView;
    private TextView childTextView;
    private String nameChild=null;
    private String nameChildId=null;
    private LinearLayout isbuy_theme_detail_list_layout03;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setAbContentView(R.layout.isbuy_theme_detail);
		// 初始化界面控件
		initViews();
		// 初始化界面监听
		initEvents();
		mHandler=new Handler();
	}
	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		//加载网路数据
		workForData();
		isbuy_theme_detail_xListView.setPullLoadEnable(true);
		isbuy_theme_detail_xListView.setXListViewListener(this);
		mList=new ArrayList<IsBuyThemeDetailReplayStore>();
		listAdapter = new IsBuyThemeDetailReplayListAdapter(IsBuyThemeDetailActivity.this, mList);
		isbuy_theme_detail_xListView.setAdapter(listAdapter);
		isbuy_theme_detail_xListView.setOnItemClickListener(this);
	}
	private void workForData(){
		// 判断当前的网络情况
		if (!(NetWorkUtil.isNetworkEnabled(IsBuyThemeDetailActivity.this) && NetWorkUtil
				.isNetworkConnected(IsBuyThemeDetailActivity.this))) {
			Toast.makeText(IsBuyThemeDetailActivity.this, "网络不可用,请检查网络...",
					Toast.LENGTH_LONG).show();
			// 查询本地数据进行填充
			//loadLocalData();
			return;
		}
		// 绑定参数
		AbRequestParams params = new AbRequestParams();
		params.put("cityCode", "11");
		params.put("pageSize", String.valueOf(pageSize));
		params.put("toPageNo", String.valueOf(currentPage));
		// 下载网络数据
		NetworkWebForStore web = NetworkWebForStore.newInstance(IsBuyThemeDetailActivity.this);
		web.findThemeReplayResultList(params, new AbHttpListener() {
			@Override
			public void onSuccess(List<?> newList) {
				mList.clear();
				if (newList != null && newList.size() > 0) {
					System.out.println("newList----"+newList);
					mList.addAll((List<IsBuyThemeDetailReplayStore>) newList);
					// 本地存储楼盘标签数据
					//storeListData((List<IsBuyThemeDetailReplayStore>) newList);
					newList.clear();
				}
				onLoad();
			}
			@Override
			public void onStart() {
				// TODO Auto-generated method stub
				super.onStart();
			}
			@Override
			public void onFinish() {
				// TODO Auto-generated method stub
				super.onFinish();
			}
			@Override
			public void onFailure(String content) {
			}
		});		
	}
	//获取更多网络数据
	public void workForListMoreData(){
		currentPage++;
		// 绑定参数
		AbRequestParams params = new AbRequestParams();
		params.put("cityCode", "11");
		params.put("pageSize", String.valueOf(pageSize));
		params.put("toPageNo", String.valueOf(currentPage));
		// 下载网络数据
		NetworkWebForStore web = NetworkWebForStore.newInstance(IsBuyThemeDetailActivity.this);
		web.findThemeReplayResultList(params, new AbHttpListener() {
			@Override
			public void onSuccess(List<?> newList) {
				if (newList != null && newList.size() > 0) {
					mList.addAll((List<IsBuyThemeDetailReplayStore>) newList);
					newList.clear();
				}
			}
			@Override
			public void onStart() {
				// TODO Auto-generated method stub
				super.onStart();
			}
			@Override
			public void onFinish() {
				// TODO Auto-generated method stub
				super.onFinish();
			}
			@Override
			public void onFailure(String content) {
			}

		});
	}	
	private void onLoad() {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
		System.out.println(df.format(new Date()));// new Date()为获取当前系统时间
		isbuy_theme_detail_xListView.stopRefresh();
		isbuy_theme_detail_xListView.stopLoadMore();
		isbuy_theme_detail_xListView.setRefreshTime(df.format(new Date()));
	}
	//向上刷新事件
	@Override
	public void onRefresh() {
		// TODO Auto-generated method stub
		mHandler.postDelayed(new Runnable() {
			@Override
			public void run() {
				mList.clear();
				workForData();
				listAdapter = new IsBuyThemeDetailReplayListAdapter(IsBuyThemeDetailActivity.this, mList);
				isbuy_theme_detail_xListView.setAdapter(listAdapter);
				onLoad();
			}
		}, 2000);
	}
    //向下加载事件
	@Override
	public void onLoadMore() {
		// TODO Auto-generated method stub
		mHandler.postDelayed(new Runnable() {
			@Override
			public void run() {
				workForListMoreData();
				listAdapter.notifyDataSetChanged();
				onLoad();
			}
		}, 2000);
	}
	private void initViews() {
		// TODO Auto-generated method stub
		isbuy_theme_detail_layout00_image01 = (ImageView) findViewById(R.id.isbuy_theme_detail_layout00_image01);
		isbuy_theme_detail_layout00_image02 = (ImageView) findViewById(R.id.isbuy_theme_detail_layout00_image02);
		isbuy_theme_detail_layout00_image03 = (ImageView) findViewById(R.id.isbuy_theme_detail_layout00_image03);
		isbuy_theme_detail_layout01_Image_itemsIcon = (CPRoundImageView) findViewById(R.id.isbuy_theme_detail_layout01_Image_itemsIcon);
		isbuy_theme_detail_layout01_text01 = (TextView) findViewById(R.id.isbuy_theme_detail_layout01_text01);
		isbuy_theme_detail_layout01_text02 = (TextView) findViewById(R.id.isbuy_theme_detail_layout01_text02);
		isbuy_theme_detail_text01 = (TextView) findViewById(R.id.isbuy_theme_detail_text01);
		isbuy_theme_detail_text02 = (TextView) findViewById(R.id.isbuy_theme_detail_text02);
		isbuy_theme_detail_text03 = (TextView) findViewById(R.id.isbuy_theme_detail_text03);

		isbuy_theme_detail_layout02_replay= (ImageView) findViewById(R.id.isbuy_theme_detail_layout02_replay);
		isbuy_theme_detail_layout02_up = (ImageView) findViewById(R.id.isbuy_theme_detail_layout02_up);
		isbuy_theme_detail_layout02_up_gone = (ImageView) findViewById(R.id.isbuy_theme_detail_layout02_up_gone);
		isbuy_theme_detail_anim=(TextView)findViewById(R.id.isbuy_theme_detail_anim);
		isbuy_theme_detail_layout02_count = (TextView) findViewById(R.id.isbuy_theme_detail_layout02_count);
		isbuy_theme_detail_layout02_down = (ImageView) findViewById(R.id.isbuy_theme_detail_layout02_down);
		isbuy_theme_detail_layout02_down_gone = (ImageView) findViewById(R.id.isbuy_theme_detail_layout02_down_gone);
		isbuy_theme_detail_anim_gone=(TextView)findViewById(R.id.isbuy_theme_detail_anim_gone);
		isbuy_theme_detail_xListView = (XListView) findViewById(R.id.isbuy_theme_detail_xListView);
		
		isbuy_theme_detail_layout03=(RelativeLayout)findViewById(R.id.isbuy_theme_detail_layout03);
		isbuy_theme_detail_layout03_edit01=(EditText)findViewById(R.id.isbuy_theme_detail_layout03_edit01);
		isbuy_theme_detail_layout03_btn01=(Button)findViewById(R.id.isbuy_theme_detail_layout03_btn01);
	}

	private void initEvents() {
		// TODO Auto-generated method stub
		isbuy_theme_detail_layout00_image01.setOnClickListener(this);
		isbuy_theme_detail_layout00_image02.setOnClickListener(this);
		isbuy_theme_detail_layout02_up.setOnClickListener(this);
		isbuy_theme_detail_layout02_down.setOnClickListener(this);
		isbuy_theme_detail_layout03_btn01.setOnClickListener(this);
		isbuy_theme_detail_layout02_replay.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		int id = v.getId();
		switch (id) {
		case R.id.isbuy_theme_detail_layout02_replay:
			//点击回复楼主
			builderName=isbuy_theme_detail_layout01_text01.getText().toString();
			showEdit(builderName);
			break;
		case R.id.isbuy_theme_detail_layout00_image01:
			finish();
			break;
		case R.id.isbuy_theme_detail_layout00_image02:
			intent = new Intent(IsBuyThemeDetailActivity.this,IsBuySearchActivity.class);
			startActivity(intent);
			break;
		case R.id.isbuy_theme_detail_layout02_up:
			showAnim(id);
			break;
		case R.id.isbuy_theme_detail_layout02_down:
			showAnim(id);
			break;
		case R.id.isbuy_theme_detail_list_layout01_01:
			//显示底部回复栏目
			String name=isbuy_theme_detail_list_layout01_name.getText().toString();
			showEdit(name);
		    break;
		case R.id.isbuy_theme_detail_layout03_btn01:
			//提交回复数据
			isbuy_theme_detail_layout03.setVisibility(View.GONE);
		    break;
		case R.id.isbuy_theme_detail_list_layout01_Image_itemsIcon:
			//显示人员详细信息
			intent=new Intent(IsBuyThemeDetailActivity.this,SearchBuildResultAuthorityDetailActivity.class);
			startActivity(intent);
		    break;
		case R.id.isbuy_theme_detail_list_layout03:
			//点击显示更多界面 
			intent=new Intent(IsBuyThemeDetailActivity.this,IsBuyThemeDetailListActivity.class);
			startActivity(intent);
			break;
		default:
			break;
		}
	}

	// 显示点击上下按钮的动画
	private void showAnim(int sourceId) {
		int count=Integer.valueOf(isbuy_theme_detail_layout02_count.getText().toString());
		System.out.println("count------>"+count);
		switch (sourceId) {
		case R.id.isbuy_theme_detail_layout02_up:
			isbuy_theme_detail_layout02_up.setVisibility(View.GONE);
			isbuy_theme_detail_layout02_up_gone.setVisibility(View.VISIBLE);
			isbuy_theme_detail_layout02_down.setVisibility(View.VISIBLE);
			isbuy_theme_detail_layout02_down_gone.setVisibility(View.GONE);
			
			isbuy_theme_detail_anim.setVisibility(View.VISIBLE);
			System.out.println("count------>"+count+1);
			isbuy_theme_detail_layout02_count.setText(String.valueOf(count+1));
			isbuy_theme_detail_layout02_up.postDelayed(new Runnable() {
				@Override
				public void run() {
					// TODO Auto-generated method stub
					isbuy_theme_detail_anim.setVisibility(View.GONE);
					
				}
			}, 1000);
			break;
		case R.id.isbuy_theme_detail_layout02_down:
			isbuy_theme_detail_layout02_down.setVisibility(View.GONE);
			isbuy_theme_detail_layout02_down_gone.setVisibility(View.VISIBLE);
			isbuy_theme_detail_layout02_up.setVisibility(View.VISIBLE);
			isbuy_theme_detail_layout02_up_gone.setVisibility(View.GONE);
			
			isbuy_theme_detail_anim_gone.setVisibility(View.VISIBLE);
			isbuy_theme_detail_layout02_count.setText(String.valueOf(count-1));
			isbuy_theme_detail_layout02_down.postDelayed(new Runnable() {
				@Override
				public void run() {
					// TODO Auto-generated method stub
					isbuy_theme_detail_anim_gone.setVisibility(View.GONE);
				}
			}, 1000);
			break;

		default:
			break;
		}
	}
	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,long id) {
		// TODO Auto-generated method stub
		//点击显示获得评论窗口
		isbuy_theme_detail_list_layout01_01=(RelativeLayout)view.findViewById(R.id.isbuy_theme_detail_list_layout01_01);
		isbuy_theme_detail_list_layout01_01.setOnClickListener(this);
		//点击头像显示详细资料
		isbuy_theme_detail_list_layout01_image=(ImageView)view.findViewById(R.id.isbuy_theme_detail_list_layout01_Image_itemsIcon);
		isbuy_theme_detail_list_layout01_image.setOnClickListener(this);
		//获得nameId和name吗,用来评论用的
		isbuy_theme_detail_list_layout01_name=(TextView)view.findViewById(R.id.isbuy_theme_detail_list_layout01_text01);
		//获得ListView中的子list,并且获得其点击事件
		listView=(XListView)view.findViewById(R.id.isbuy_theme_detail_list_xListView);
		listView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view2, int position,long id) {
				// TODO Auto-generated method stub
				//获得子listview的点击事件
				childTextView=(TextView)view2.findViewById(R.id.isbuy_theme_detail_list_layout03_text01);
				nameChild=childTextView.getText().toString();
				showEdit(nameChild);
			}
		});
	}
	//显示下方按钮
	private void showEdit(String name){
		StringBuffer stringBuffer=new StringBuffer();
		stringBuffer.append("回复@");
		stringBuffer.append(name);
		isbuy_theme_detail_layout03_edit01.setText(stringBuffer.toString());
		isbuy_theme_detail_layout03.setVisibility(View.VISIBLE);
		isbuy_theme_detail_layout03_edit01.setFocusable(true);
	}
}

至此全部介绍完毕,具体实现方法已经在代码中了。其中做的时候也遇到的bug是,父listview中的个别 控件一直无法获得焦点,主要需要在ListView中的最外层布局文件中进行属性的声明

 android:descendantFocusability=

beforeDescendants:viewgroup会优先其子类控件而获取到焦点

afterDescendants:viewgroup只有当其子类控件不需要获取焦点时才获取焦点

blocksDescendants:viewgroup会覆盖子类控件而直接获得焦点

可以根据不同情况选择不同的属性选择,实现不同的效果。




评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值