有以下代码:
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>
但是点击子视图没有消息!我该如何解决?
答案 0 :(得分:0)
尝试添加:
return super.onChildClick(parent, v, groupPosition, childPosition, id);
而不是假。这对你有用吗?