【问题标题】:Android compound button through xml fileAndroid复合按钮通过xml文件
【发布时间】:2011-11-10 14:24:45
【问题描述】:

我正在尝试使用android的内置控件CompoundButton,但是我在xml中使用它没有运气,这是我的代码

<CompoundButton
    android:id="@+id/mini_recorder_play"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_weight="1"
    android:background="@drawable/play_d" />

膨胀时抛出异常。

【问题讨论】:

  • 似乎复合按钮是抽象的,所以它不起作用。

标签: android button android-button


【解决方案1】:

CompoundButton 是一个抽象类,你不能直接实例化它。如果这些小部件都不符合您的需求,您必须实例化其子类之一(例如 CheckBoxRadioButtonToggleButton)或创建您自己的自定义子类。

HTH

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-29
    • 2013-01-09
    • 1970-01-01
    • 1970-01-01
    • 2014-09-03
    相关资源
    最近更新 更多