Ganjira
Ganjira

Reputation: 976

The method setButton is ambiguous on AlertDialog

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

Answers (1)

user1521536
user1521536

Reputation:

First, don't hardcode 1, there are some constants in class DialogInterface: BUTTON_NEGATIVE, BUTTON_NEUTRAL, BUTTON_POSITIVE

And, there are overloaded methods:

You passed null to the third parameter, so the compiler didn't know which method you wanted to use.

Upvotes: 4

Related Questions