Search code examples
androidcheckboxpreference

Can we show a button instead of icon with a CheckboxPreference


I am working with checkBoxPreference from few days,

have figured out:

  1. how to display icon with checkBoxPreference,
  2. how to change colour of title and summary

Now, I need to add a button instead of the icon. So any one here has any ideas on this...

I have tried to add a button in onCreateView in the preferenceFragment but no luck... Can't add it in the xml as I am adding checkBoxPreference dynamically.

Thanks,


Solution

  • We need to define our own layout which can be used, using two lines mentioned by @Prativa, example of a good layout to add widgets to, can be seen at this link:

    CheckBoxPreference with own layout

    Furthermore, you would also need to write a custom checkBoxPreference class if you want to modify any of the properties of the widgets added to this custom layout.