例如,在应用程序羽,当你点击一个ListView项目(鸣叫),它扩展其下表现出一定的操作(回复,链接,转推等)。我怎样才能复制在我的应用程序这种行为?我希望能够点击一个ListView项目,然后展开与我自己的操作(选择的项目)。
For example, in the application Plume, when you click on a ListView item (a tweet), it expands beneath it to show some actions (reply, links, retweet, etc.). How can I replicate this behavior in my application? I want to be able to click a ListView item and then "expand" it with my own actions (for the item selected).
截图例如:
什么是这里所使用的UI设计模式?
What is the UI design pattern being used here?
您必须创建它自己。你应该创建一个扩展自定义适配器 BaseExpandableListAdapter
和 getChildView
你应该把这些按钮在一个水平的LinearLayout
与 TextViews
,并设置的TextView
的机器人:drawableTop
与您要使用的图标
You have to create it for yourself. You should create a custom adapter which extends BaseExpandableListAdapter
and in getChildView
you should put the buttons in a horizontal LinearLayout
with TextViews
and set the TextView
's android:drawableTop
with the icons you want to use.
一个非常简单的使用此布局的:
A very simple use of this layout:
<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>
您可以使用您可绘制和字符串。这只是一种方法。
You can use your drawables and strings. It's just an approach.