Reputation: 976
I have this method:
alert.setButton(1, "OK", null);
but it doesn't work, because I got this alert on my sdk:
Description Resource Path Location Type The method setButton(int, CharSequence, Message) is ambiguous for the type AlertDialog (...)
How to resolve that? THanks in advance
Upvotes: 2
Views: 3486
Reputation:
First, don't hardcode 1
, there are some constants in class DialogInterface
: BUTTON_NEGATIVE
, BUTTON_NEUTRAL
, BUTTON_POSITIVE
…
And, there are overloaded methods:
setButton(int whichButton, CharSequence text, DialogInterface.OnClickListener listener)
setButton(int whichButton, CharSequence text, Message msg)
You passed null
to the third parameter, so the compiler didn't know which method you wanted to use.
Upvotes: 4