如何保持 ExpandableListView 打开?

发布于 2024-11-28 12:53:21 字数 144 浏览 5 评论 0原文

我正在研究 ExpandableListView 我已经完成了工作,现在我只想做的一件事是我不希望 ListView 在单击可扩展列表视图时变为 DropDown,而是希望显示它与所有项目一起打开无需对其进行任何单击即可显示在内部。

谁能告诉我具体该怎么做。

I am working on the ExpandableListView I have completed the work, now only one thing that I want to do is I don't want the ListView to be DropDown on click of the Expandable List View rather I want to show it opened with all the Items displayed inside without performing any click on them.

Can anyone tell me how can i do that particularly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

尴尬癌患者 2024-12-05 12:53:21

对每个组执行此操作以展开它们:

listView1.expandGroup(int groupPosition);

如果您想防止组崩溃,请执行以下操作:

listView1.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener()
{
    public boolean onGroupClick(ExpandableListView arg0, View itemView, int itemPosition, long itemId)
    {
        listView1.expandGroup(itemPosition);
        return true;
    }
});

Do this for every one of the groups to expand them:

listView1.expandGroup(int groupPosition);

If you want to prevent group collapse, then do this:

listView1.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener()
{
    public boolean onGroupClick(ExpandableListView arg0, View itemView, int itemPosition, long itemId)
    {
        listView1.expandGroup(itemPosition);
        return true;
    }
});
忆依然 2024-12-05 12:53:21

解决方案:- 始终将可扩展列表保持在扩展模式
实际上非常简单,您不需要执行任何操作,只需将这一行放入适配器的 getGroupView 中,并且您的可扩展列表视图始终处于打开/扩展状态:--

@Override
    public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {

        View v = convertView;
        your_expandableListview.expandGroup(groupPosition);
        return v;
    }

这肯定有效...享受...!

Solution:- To Keep The Expandable list in Expanded mode all the times
It is actually very simple you dont need to do anything but just put this one line in your getGroupView of your adapter and your expandablelistview always be in opened/expanded state:--

@Override
    public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {

        View v = convertView;
        your_expandableListview.expandGroup(groupPosition);
        return v;
    }

This works for sure... Enjoy..!

各自安好 2024-12-05 12:53:21

打开 ExpandableListView 组:

 listView.expandGroup(itemPosition);

折叠 ExpandableListView 组:

 listView.collapseGroup(itemPosition);

Open ExpandableListView Group:

 listView.expandGroup(itemPosition);

Collapse ExpandableListView Group:

 listView.collapseGroup(itemPosition);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文