相关疑难解决方法(0)

Android中的多级ExpandableListView

我正在尝试从给定的未知大小和级别的类别列表创建类别树.所以我正在尝试创建一个可以包含2个以上级别的通用可扩展列表.一般的想法是在每个孩子的布局中添加另一个ExpandableListView.问题是第二级别不会打开,看起来它会覆盖孩子或其他东西.以下是结果的一些屏幕截图:

这是打开之前的样子在此输入图像描述

打开第一个选项后:(它应该是空的)

在此输入图像描述

现在打开第二个:(有4个孩子,其中一个孩子有自己的孩子)

在此输入图像描述

正如您所看到的那样,第三个选项在点击打开之后看起来已经呈现了另一个选项或其他内容:

在此输入图像描述

除了改变箭头的状态之外什么都不做.至少它试图打开它......

这是代码:

CatAdapter.java :(扩展BaseExpandableListAdapter) http://pastebin.com/6yUTkMbJ

Category.java: http://pastebin.com/E7yWwpna

catitem.xml:http://pastebin.com/G5MPT3Ua

用法:http: //pastebin.com/Wk0FqJhn

很抱歉这个问题很长,我试图尽可能清楚.

提前致谢!对不起,我的英语不好!

编辑:

我最终为这个任务制作了一个自定义视图,谢谢大家的答案!

java android expandablelistview

10
推荐指数
1
解决办法
2万
查看次数

扩展多级ExpandableListView的问题

我有一个多级(3级,Root - > Parent - > Child)ExpandableListView包含也是ExpandableListViews的子级.我没有填补它们的问题; 但是,当我第一次显示Activity(onCreate)时,我需要扩展Parent级别中的特定项.

我成功地扩展了Parent的相关Root项,但我似乎无法扩展Parent项.调用给定的侦听器,但结果不会反映在我的多级列表中.

我称之为扩展的活动:

public class Activity {
    private int groupToExpand = 4, childToExpand = 3;
    protected void onCreate(Bundle savedInstance) {
        final ExpandableListView elv = (ExpandableListView) findViewById(R.id.elv);
        if (arrayList!= null && !arrayList.isEmpty()) {
            elv.setAdapter(new RootAdapter(this, arrayList);
            // this selects the correct group, but doesn't expand the child.
            elv.setSelectedChild(groupToExpand, childToExpand, true); 
            elv.expandGroup(groupToExpand); // this works.
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我的Root适配器:

public class RootAdapter extends BaseExpandableListAdapter {

private List<Objects> arrayList;
private Context context;
private LayoutInflater inflater;

public …
Run Code Online (Sandbox Code Playgroud)

android expandablelistview multi-level

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×2

expandablelistview ×2

java ×1

multi-level ×1