Android 在可展开列表视图中隐藏组指示符
我想在我的所有列表元素中的n可展开列表视图中隐藏组展开/折叠指示器,并显示一个图像来代替指示器。我使用以下方法使指示器颜色透明:Android 在可展开列表视图中隐藏组指示符,android,android-layout,android-listview,expandablelistview,expand,Android,Android Layout,Android Listview,Expandablelistview,Expand,我想在我的所有列表元素中的n可展开列表视图中隐藏组展开/折叠指示器,并显示一个图像来代替指示器。我使用以下方法使指示器颜色透明: android:groupIndicator="@android:color/transparent 但这不允许我将图像放置在指示器原来所在的位置,因此我需要一种新的方法来执行此操作。实现您自己的BaseExpandableListAdapter: public class MyExpandableListAdapter extends BaseExpandabl
android:groupIndicator="@android:color/transparent
但这不允许我将图像放置在指示器原来所在的位置,因此我需要一种新的方法来执行此操作。实现您自己的
BaseExpandableListAdapter
:
public class MyExpandableListAdapter extends BaseExpandableListAdapter {
...
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(mContext);
View rowView = inflater.inflate(R.layout.list_group_item, null);
return rowView;
}
...
}
列表\组\项目
应包含所需的组指示器图像。不要忘记禁用本机指示:
expandableListView.setGroupIndicator(null);
如果elv是您的ExpandableListView,则需要设置android:groupIndicator=“@null”(在Java中,当您初始化视图时):
elv.setGroupIndicator(null)代码>谢谢@fraggjkee这就是我要找的。