So my ExpandableListView
has group rows that are defined like :
group_row.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/GroupName"
style="@style/ListViewRowStyle"
android:paddingLeft="40dp"
android:textSize="18sp" >
</TextView>
<ImageView
android:id="@+id/Menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:contentDescription="@string/default_content_description_text"
android:src="@drawable/ic_menu_moreoverflow_normal_holo_light" >
</ImageView>
</RelativeLayout>
When you click on the TextView
it will expand or collapse depending on whether or not the child rows are currently displayed. I have attached an OnClickListener
to the ImageView
in the group row. When this ImageView
is clicked I launch a PopupMenu
like the images below :
Once the PopupMenu
is displayed and one of the actions is clicked, I would like to perform an action on all children of the group. The problem is that I cannot determine the row in which the ImageView
was clicked.
The only way I have figured out how to apply an action to all children is with a ContextMenu
like the image below :
I want to avoid using a ContextMenu
because a LongClick on a group row may not be obvious for a user to figure out that it would bring up some actions to perform on the children rows. I think the more obvious design is to anchor a PopupMenu
to an ImageView
(in my case a menu icon) and have the action be applied to the children rows of that group. How can I get this functionality with a PopupMenu
?