簡體   English   中英

ExpandableListView中的元素不可點擊:

[英]Elements in ExpandableListView are not clickable:

有以下代碼:

            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>

但是沒有通過子視圖單擊顯示的消息! 我該如何解決?

嘗試添加:

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

而不是假的。 它能為您提供幫助嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM