例如,在应用程序 Plume 中,当您单击 ListView 项(推文)时,它会在其下方展开以显示一些操作(回复、链接、转推等)。如何在我的应用程序中复制此行为?我希望能够单击一个 ListView 项目,然后用我自己的操作(对于所选项目)“展开”它。
截图示例:
这里使用的 UI 设计模式是什么?
最佳答案
您必须自己创建它。您应该创建一个扩展 BaseExpandableListAdapter
的自定义适配器,并且在 getChildView
中,您应该将按钮放在带有 TextViews
的水平 LinearLayout
中> 并使用您要使用的图标设置 TextView
的 android: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/