Get the drawable used as a Checkbox image

Asked

Viewed 35 times

3

Whenever I have saved the image associated with a checkbox through the method imagem = minha_checkbox.getButtonDrawable(); always gives me a mistake called call requires API level 23 (current min is 17)

How can I fix this?

1 answer

5


The method getButtonDrawable() was only introduced in the Checkbox(Compoundbutton) class in version 23 of the API.

Has two solutions:

  • Changes the minimum version of the application to 23(android:minSdkVersion="23").
  • Refers to the class Compoundbuttoncompat and uses its static method getButtonDrawable():

    imagem = CompoundButtonCompat.getButtonDrawable(minha_checkbox);
    

    Note: Requires Android Support Library, Revision 23.0.1 or higher.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.