ExpandableListViews有什么用? [英] What's the deal with ExpandableListViews?

查看:115
本文介绍了ExpandableListViews有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我想创建一个可扩展列表视图",并查看我所看到的每个地方,似乎他们在为自己的功能编写可扩展列表视图".

So I want to create an Expandable List View and every place I look, it seems like they are programming in their own functionality for the Expandable List View themselves.

您真的必须这样做吗,还是有不需要任何编程的基本功能?

Do you really have to do that or is there a base functionality that doesn't require any programming?

推荐答案

所以我用了这个图书馆来实现展开和折叠行为,并且它就像一种魅力.

So I have used this library to achieve the expansion and collapse behavior and it works like a charm.

<com.github.florent37.expansionpanel.ExpansionHeader
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    app:expansion_headerIndicator="@id/headerIndicator"
    app:expansion_layout="@id/expansionLayout"
    app:expansion_toggleOnClick="true">

    <!-- HEADER -->

    ...
    <!-- HEADER INDICATOR -->
    <ImageView
           android:adjustViewBounds="true"
           android:id="@+id/headerIndicator"
           android:layout_gravity="center_vertical|right"
           android:layout_height="wrap_content"
           android:layout_marginLeft="16dp"
           android:layout_width="wrap_content"
           app:srcCompat="@drawable/ic_expansion_header_indicator_grey_24dp" />


</com.github.florent37.expansionpanel.ExpansionHeader>

<com.github.florent37.expansionpanel.ExpansionLayout
    android:id="@+id/expansionLayout"
    android:layout_height="wrap_content"
    android:layout_width="match_parent">

    <!-- CONTENT -->

</com.github.florent37.expansionpanel.ExpansionLayout>

像这样在Activity中添加一个侦听器

Attach a listener in Activity like this

ExpansionLayout expansionLayout = findViewById(...);
expansionLayout.addListener(new ExpansionLayout.Listener() {
    @Override
    public void onExpansionChanged(ExpansionLayout expansionLayout, boolean expanded) {

    }
});

这篇关于ExpandableListViews有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆