android - 如何复制此 UI 模式 : click ListView item and expand below it?

标签 android listview expandablelistview

例如,在应用程序 Plume 中,当您单击 ListView 项(推文)时,它会在其下方展开以显示一些操作(回复、链接、转推等)。如何在我的应用程序中复制此行为?我希望能够单击一个 ListView 项目,然后用我自己的操作(对于所选项目)“展开”它。

截图示例:

enter image description here

这里使用的 UI 设计模式是什么?

最佳答案

您必须自己创建它。您应该创建一个扩展 BaseExpandableListAdapter 的自定义适配器,并且在 getChildView 中,您应该将按钮放在带有 TextViews 的水平 LinearLayout 中> 并使用您要使用的图标设置 TextViewandroid:drawableTop

这个布局的一个非常简单的使用:

<LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/replyText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:text="@string/app_name"
            android:drawableTop="@drawable/ic_launcher" />
        <TextView
            android:id="@+id/someText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/app_name"
            android:layout_margin="5dp"
            android:drawableTop="@drawable/ic_launcher" />
        <TextView
            android:id="@+id/otherText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:text="@string/app_name"
            android:drawableTop="@drawable/ic_launcher" />

</LinearLayout>

您可以使用可绘制对象和字符串。这只是一种方法。

关于android - 如何复制此 UI 模式 : click ListView item and expand below it?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14186398/

相关文章:

Android 不可移动的快捷方式

Android MediaRecorder : start failed: -2147483648

android - 如何在 Android 2.3.3 的 ListView 中突出显示选定的行。 (HoloeveryWhere + ABS)

android - 来自 Json 的可扩展 ListView

java - 可扩展 ListView 默认选择

android - 禁用 ExpandableListView 的折叠

java - "normal"两个图像与 alpha 混合的问题

android - 为什么 KILL_BACKGROUND_PROCESSES 不起作用?

android - ListView 上方 ViewPager 中的 float 操作按钮

java - 在没有主节点的情况下,在 android 中从 JSON 生成 ListView ?