我有一个包含 5 个按钮的小部件。如何在单击按钮时为按钮实现这种行为,小部件下的可扩展面板会出现更多按钮?如果单击另一个按钮,则会出现另一个面板...
所以我的初始小部件布局如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:background="@drawable/smc_icon"
android:textColor="#FFFFFF"
/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:background="@drawable/smc_icon"
android:textColor="#FFFFFF"
/>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:background="@drawable/smc_icon"
android:textColor="#FFFFFF"
/>
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:background="@drawable/smc_icon"
android:textColor="#FFFFFF"
/>
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:background="@drawable/smc_icon"
android:textColor="#FFFFFF"
/>
另一个问题:我可以实现这样一个活动,它呈现与我在资源 xml 文件中定义的一样多的按钮吗?