Vaibhav Mishra
Vaibhav Mishra

Reputation: 12102

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.

Upvotes: 3

Views: 3820

Answers (1)

devunwired
devunwired

Reputation: 63293

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

Upvotes: 11

Related Questions