I am working with an ExpandableListView in my application. It worked fine until I decided to add an ImageButton to the end of it. Here is my XML:
This is my group row:
<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开发者_JAVA技巧="true">
</ImageButton>
Now, the ExpandableListView will not expand. Does anyone know what the problem could be?
EDIT: Okay, I understand what the problem is. I have a view that is focusable that causes the onItemClickListener not to be called when I click on a row. I implemented an onClickListener that captures the click, but I do not know how to expand the row. Can anyone help out? Here is the code that I have inside of my custom Adapter:
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 himself has answered your question rather succinctly in this group discussion.
精彩评论