单击按钮时,Android会展开窗口小部件,并动态向面板呈现按钮

时间:2012-09-12 10:21:08

标签: android android-widget

我有一个包含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文件中定义的按钮数量吗?

0 个答案:

没有答案