0

有以下代码:

            mListOfExistedMessages.setAdapter(new ExistedTasksExpandableListAdapter(context, persons));
            mListOfExistedMessages.setOnChildClickListener(new OnChildClickListener() {

                @Override
                public boolean onChildClick(ExpandableListView parent,
                        View v, int groupPosition, int childPosition,
                        long id) {
                    Toast.makeText(ExistedMessagesActivity.this, "1", 
                            Toast.LENGTH_LONG).show();
                    return false;
                }

            });
            mListOfExistedMessages.setItemsCanFocus(false);

ExistedTasksExpandableListAdapter 是我的自定义适配器,并且适配器代码运行良好(显示组和子的自定义视图)。子布局代码:

<?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:focusable="false"
    android:orientation="horizontal"
    android:padding="10dip"
    android:paddingLeft="15dip" >

    <CheckBox
        android:id="@+id/listItemExistedMessageChecked"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:gravity="center"
        android:text="" />

    <LinearLayout
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_weight="1.7"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/listItemExistedMessageText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:maxLines="2"
            android:text="Small Text"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <TextView
            android:id="@+id/listItemExistedMessageRepeating"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:text="Small Text"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textStyle="italic" />
    </LinearLayout>

    <View
        android:layout_width="5dip"
        android:layout_height="match_parent"
        android:layout_marginLeft="5dip"
        android:background="#1874CD"
        android:focusable="false"
        android:focusableInTouchMode="false" />

    <LinearLayout
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:gravity="center"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:text="Next event:"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/listItemExistedMessageDateTime"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:gravity="center"
            android:text="Small Text"
            android:textAppearance="?android:attr/textAppearanceMedium" />
    </LinearLayout>

</LinearLayout>

但是子视图点击没有消息!我该如何解决?

4

1 回答 1

0

尝试添加:

    return super.onChildClick(parent, v, groupPosition, childPosition, id);

而不是假的。它能为您提供帮助吗?

于 2012-11-24T14:36:24.803 回答