所以我的ExpandableListView具有定义如下的组行:
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>
当您单击TextView时,它将展开或折叠,具体取决于当前是否显示子行.我已将OnClickListener附加到组行中的ImageView.单击此ImageView时,我启动一个PopupMenu,如下图所示:
显示PopupMenu并单击其中一个操作后,我想对该组的所有子项执行操作.问题是我无法确定单击ImageView的行.
我想出如何将动作应用于所有孩子的唯一方法是使用ContextMenu,如下图所示:
我想避免使用ContextMenu,因为组行上的LongClick可能不明显,用户无法确定它会对子行执行某些操作.我认为更明显的设计是将PopupMenu锚定到ImageView(在我的例子中是菜单图标)并将操作应用于该组的子行.如何使用PopupMenu获得此功能?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。