gpt4 book ai didi

android - ExpandableListView 组行中的 ImageButton 导致不触发 onClickListener

转载 作者:行者123 更新时间:2023-11-29 18:18:19 25 4
gpt4 key购买 nike

我正在我的应用程序中使用 ExpandableListView。它工作正常,直到我决定在它的末尾添加一个 ImageButton。这是我的 XML:

这是我的组行:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<TextView
android:text="location"
android:layout_height="45dp"
android:layout_width="250dp" style="@style/listResultsTitle"
android:id="@+id/results_location_row"
android:gravity="center_vertical"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="40dp">
</TextView>
<TextView
android:text="ad"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_height="30dp"
android:layout_width="wrap_content"
style="@style/listResults"
android:id="@+id/results_ad_row"
android:layout_alignBottom="@+id/results_location_row"
android:layout_alignLeft="@+id/results_location_row"
android:layout_alignRight="@+id/results_location_row">
</TextView>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/prox_order"
android:src="@drawable/ic_menu_add"
android:background="@android:color/transparent"
android:layout_centerVertical="true"
android:layout_alignParentRight="true">
</ImageButton>

现在,ExpandableListView 将不会展开。有谁知道是什么问题?

编辑:好的,我明白问题出在哪里了。我有一个可聚焦的 View ,导致当我单击一行时不调用 onItemClickListener。我实现了一个捕获点击的 onClickListener,但我不知道如何展开该行。任何人都可以帮忙吗?这是我的自定义适配器中的代码:

 v.setOnClickListener(new OnItemClickListener(groupPosition, this))
private class OnItemClickListener implements OnClickListener{
private int pos;
MySimpleExpandableListAdapter adapter;
OnItemClickListener(int groupPosition, MySimpleExpandableListAdapter _adapter){
pos = groupPosition;
adapter = _adapter;
}
@Override
public void onClick(View v) {
Log.e("Adapter", "Row clicked: #" + String.valueOf(pos));
}
}

~Nemisis7654

最佳答案

Romain Guy 本人在 group discussion 中相当简洁地回答了您的问题.

关于android - ExpandableListView 组行中的 ImageButton 导致不触发 onClickListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6929906/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com