Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android compound button through xml file

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.

like image 986
Vaibhav Mishra Avatar asked Jun 25 '26 05:06

Vaibhav Mishra


1 Answers

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

like image 51
devunwired Avatar answered Jun 26 '26 21:06

devunwired



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!