Android ExpandableListView组行中的ImageButton导致onClickListener未被激发
我正在应用程序中使用ExpandableListView。它工作得很好,直到我决定在它的末尾添加一个ImageButton。以下是我的XML: 这是我的分组行:Android ExpandableListView组行中的ImageButton导致onClickListener未被激发,android,imagebutton,expandablelistview,Android,Imagebutton,Expandablelistview,我正在应用程序中使用ExpandableListView。它工作得很好,直到我决定在它的末尾添加一个ImageButton。以下是我的XML: 这是我的分组行: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height
<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>
~Nemisis7654罗曼·盖伊本人在这篇文章中非常简洁地回答了你的问题。你看。我看到了,但这并没有解决我的问题。我把图像显示在我想要的地方。问题是,现在图像已经存在,它似乎没有在列表上注册单击,因此列表不会展开,我也看不到子行。谢谢。这无疑帮助我弄清了问题所在。现在开始解决它…好的,我编辑了我的问题。你认为你能帮忙吗?对不起,我不熟悉ExpandableListView。祝你好运无论如何,谢谢你。你帮我找出了问题的原因。非常感谢。
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));
}
}