Android通过xml文件实现复合按钮
我正在尝试使用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" />
它在膨胀时抛出异常。
I am trying to use android's built in control CompoundButton
, however I have no luck using it in xml, here is my code
<CompoundButton
android:id="@+id/mini_recorder_play"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_weight="1"
android:background="@drawable/play_d" />
it is throwing exception while inflating.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CompoundButton
是一个抽象类,不能直接实例化它。您必须实例化其子类之一(例如CheckBox
、RadioButton
、ToggleButton
),或者如果这些小部件都不适合您,则创建您自己的自定义子类。需要。华泰
CompoundButton
is an abstract class, you cannot instantiate it directly. You must either instantiate one of its subclasses (e.g.CheckBox
,RadioButton
,ToggleButton
) or create your own customized subclass if none of those widgets fits your needs.HTH