例如,在应用程序 Plume 中,当您单击 ListView 项目(推文)时,它会在其下方展开以显示一些操作(回复、链接、转发等)。如何在我的应用程序中复制此行为?我希望能够单击 ListView 项目,然后用我自己的操作“扩展”它(对于选定的项目)。
截图示例:
这里使用的 UI 设计模式是什么?
例如,在应用程序 Plume 中,当您单击 ListView 项目(推文)时,它会在其下方展开以显示一些操作(回复、链接、转发等)。如何在我的应用程序中复制此行为?我希望能够单击 ListView 项目,然后用我自己的操作“扩展”它(对于选定的项目)。
截图示例:
这里使用的 UI 设计模式是什么?
你必须为自己创造它。您应该创建一个扩展的自定义适配器,BaseExpandableListAdapter
并且getChildView
您应该将按钮水平放置LinearLayout
,并使用您要使用的图标TextViews
设置TextView
's 。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>
您可以使用您的可绘制对象和字符串。这只是一种方法。
我不确定 Plume 是否使用这个库,但我已经成功使用Android - SlideExplandableListView来实现这个功能。