通过xml文件实现Android复合按钮
我正在尝试使用android的内置控件通过xml文件实现Android复合按钮,android,button,android-button,Android,Button,Android Button,我正在尝试使用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_
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" />
它在膨胀时引发异常。
CompoundButton
是一个抽象类,不能直接实例化它。您必须实例化它的一个子类(例如,CheckBox
,RadioButton
,ToggleButton
),或者创建自己的自定义子类(如果这些小部件都不适合您的需要)
HTH似乎compoundbutton是抽象的,因此无法工作。