1

By default, DialogPreference has two buttons - OK and Cancel. I want to leave only the OK button and remove the cancel button - how can i do that?

Erik Sapir
  • 23,209
  • 28
  • 81
  • 141

2 Answers2

3

You can easily remove the cancel button or okey button just set the setNegativeButtonText(null); for cancel and setPositiveButtonText(null); for okey.

peter_budo
  • 1,748
  • 4
  • 26
  • 48
Suat KARAKUSOGLU
  • 622
  • 6
  • 14
0

Take a look at this example: http://developer.android.com/guide/appendix/faq/commontasks.html#alerts

You should only need the setPositiveButton attibute.

R Hughes
  • 640
  • 9
  • 22
  • I don't need an alert but a DialogPreferene – Erik Sapir Mar 02 '11 at 08:20
  • I caught that after I posted then couldn't get back in to update. I see your difficulty. Not much seems to be available on customizing the buttons. If I find anything, I'll send it on. – R Hughes Mar 03 '11 at 22:36
  • It looks like you may have to subclass it to create your own. I've never done that, but I found a good example to start with. Hope it helps. http://stackoverflow.com/questions/4505845/concise-way-of-writing-new-dialogpreference-classes – R Hughes Mar 03 '11 at 22:43