是否可以在可扩展列表中自定义子项?
我目前正在开展一个项目,我需要以下内容:
- MainGroup 1 (Expandable)
- SubGroup 1 (Expandable)
- SubSubGroup 1 (Expandable)
- Child View
- Child View
- ...
- SubSubGroup 2 (Expandable)
- Child View
- Child View
- ...
- SubGroup 2 (Expandable)
- SubSubGroup 3 (Expandable)
- Child View
- ...
- SubSubGroup 4 (Expandable)
- Child View
- ...
- SubGroup 3 (Expandable)
- Child View
- ...
- MainGroup 2 (Expandable)
- ...
Run Code Online (Sandbox Code Playgroud)
在最这将是一个ExpandableListView内部的ExpandableListView内部的ExpandableListView-这么3层ExpandableListView:
MainGroup …我有一个可扩展的列表视图.我已经放了一些虚拟数据,并且evrything似乎没问题,但是当我运行应用程序时,所有组都处于折叠模式,当我点击它们时它们不会生效.这是截图:

组的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="wrap_content"
android:background="@color/bg_slider"
android:orientation="horizontal" >
<TextView
android:id="@+id/tvRecipeName"
style="@style/normal_text.bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="5dp"
android:focusable="false"
android:lines="1"
android:maxLines="1"
android:text="@string/dd_title" />
<ImageButton
android:id="@+id/ibDeleteRecipe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:background="@color/transparent"
android:contentDescription="@string/cd"
android:focusable="false"
android:src="@android:drawable/ic_menu_delete" />
<View
android:layout_width="1dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/tvRecipeName"
android:focusable="false" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
孩子的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="wrap_content"
android:background="@color/White"
android:gravity="left|center_vertical" >
<View
android:layout_width="1dp"
android:layout_height="35dp"
android:layout_toLeftOf="@+id/tvIngredient"
android:focusable="false" />
<TextView
android:id="@+id/tvIngredient"
style="@style/normal_text_black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="30dp"
android:layout_marginRight="5dp"
android:lines="1"
android:maxLines="1"
android:text="@string/dd_title"
android:focusable="false" />
<ImageButton
android:id="@+id/ibDeleteIngredient"
android:layout_width="wrap_content" …Run Code Online (Sandbox Code Playgroud) 如何显示3级以上的可扩展列表视图,我只获得3级可扩展的示例.
参考:三级可扩展列表
在这个例子中,他在getChildViewParentLevel的方法中 添加了一个可扩展列表 BaseExpandableListAdapter:
CustExpListview SecondLevelexplv = new CustExpListview(Home.this);
SecondLevelexplv.setAdapter(new SecondLevelAdapter());
SecondLevelexplv.setGroupIndicator(null);
return SecondLevelexplv;
Run Code Online (Sandbox Code Playgroud)
所以我同样在getChildView方法中添加一个可扩展列表SecondLevelAdapter.
它的工作但是View不像3级可扩展列表视图那样正常.我读过这个:
请指导或分享我在android中的多级可扩展显示的合适示例.
谢谢,
RecyclerView已经与Android L一起推出,是AppCompat v7库的一部分.然后我决定用这个全新的应用更新我的应用程序RecyclerView来取代我ListView的.为此,当设置一个LayoutManagerfor RecyclerView,我正在使用LinearLayoutManager,它工作正常.
这是艰难的事情:当我想改变我ExpandableListView的时候RecyclerView.由于谷歌没有创建" ExpandableLayoutManager",这是非常棘手的,我无法做到这一点.
该文件提到了儿童,但它似乎是RecyclerView儿童自己的根本观点.
有人有解决方法或一些线索吗?或至少一些信息,比如从哪里开始,以便我可以实现自己的LayoutManager.
android expandablelistview android-5.0-lollipop android-recyclerview
我有一个实现的类expandable list activity.
在XML代码中(或者我可以在java中完成),我设置fastScrollEnabled为true.这样做可以实现快速滚动.但快速滚动仅适用于列表的顶部.就像我可以使用fastscroll拇指栏滚动整个列表,但只能在滚动条的顶部工作.它与整个列表不成比例.我可以将拇指栏拖动到列表的底部,但它不会滚动,因为listview它已经滚动到底部,因为它的奇怪行为只能在列表的顶部工作.
令我感到困惑,如果需要,我可以尝试澄清更多......
我确实实现了一个自定义 BaseExpandableListAdapter.
我想只在父元素之间放置divider.当我设置
android:divider="@drawable/divider"Run Code Online (Sandbox Code Playgroud)android在父元素之间创建分隔符,但也在子元素之间创建分隔符.当我添加android:childDivider="@color/transparent"Run Code Online (Sandbox Code Playgroud)android删除子元素之间的分隔符,但它们之间的空闲空间仍然存在.为什么?我试过了android:dividerHeight="0dp"Run Code Online (Sandbox Code Playgroud) 但什么都没发生.
我想在父元素之间设置分隔符,但我不希望子元素之间有任何分隔符或空格.
任何想法怎么做?
默认行为ExpandableListView是在单击其标题时折叠组.有可能防止这种情况发生吗?
我试过了:
OnTouchListener在列表上设置.这会干扰滚动.OnGroupClickListener在列表中设置(in onCreate()).这适用于第一次点击之后的所有点击.有没有其他人完成这个?为什么可能会OnGroupClickListener错过第一次点击?
提前感谢您的建议.
我希望我ExpandableListView在用户展开组时自动滚动,以便展开的组标题位于屏幕顶部.我试过了smoothScrollToPosition,但这只是确保扩展组在屏幕上的某个位置可见.我想明确滚动它,以便扩展组位于顶部,如下例所示:
Before expanding Group 3: After expanding Group 3:
+=================+ +=================+
| Group 1 | | Group 3 |
+-----------------+ +-----------------+
| Group 2 | | Grp 3 Child 1 |
+-----------------+ +-----------------+
| Group 3 | | Grp 3 Child 2 |
+-----------------+ +-----------------+
| Group 4 | | Group 4 |
+=================+ +=================+
Run Code Online (Sandbox Code Playgroud) 我正在尝试实现一个回收视图,其行为类似于下面的草图:
这个想法是有一个父列表,当点击父列表中的列表项时,该列表项显示包含它自己的数据的子列表.当在子列表中点击列表项时,将反映该子项的值,并更新父列表项中父项的值.
我试图让它在过去3天工作无济于事.我尝试使用AdvancedReyclerview库,但对于像我这样的初学者来说,这是一件非常混乱的事情,特别是在传入数据时没有意义.我复制并粘贴了我需要的文件以获得最小的工作版本,但我不知道如何将我的数据传递到recyclerview以及如何使用新选择的值更新它.
甚至可以做我正在尝试做的事情,还是我离开了我的深度?
如果仍然难以理解,我可以解释一下.
编辑:有人建议我使用ExpandableListView而不是RecyclerView.有什么想法吗?