我怎样才能复制此UI模式:点击ListView项并展开它下面?模式、UI、ListView

2023-09-05 23:26:44 作者:蜜桃软妹

例如,在应用程序羽,当你点击一个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.