android - setPositiveButton in AlertDialog, using strings? -


i'm trying add string following alert box's positive button, keeps spamming out error messages.

alertdialog.builder builder = new alertdialog.builder(this); builder.setmessage(r.string.checknetwork).settitle(         r.string.checknetworktitle); builder.seticon(r.drawable.ic_warning); builder.setpositivebutton(android.r.string.continue, new warningcontinue()); alertdialog dialog = builder.create(); dialog.show(); 

any help? seem work title , message, not button...

thanks in advance.

edit: error says:

the method setpositivebutton(int, dialoginterface.onclicklistener) in type alertdialog.builder not applicable arguments (class, warningcontinue)

so seems expect integer, wondering if there's way use strings localization-purposes?

edit2:

ok hell. problem lied in string name; won't let me name string continue reason. o_o

you don't want use "android.r.string.continue". "package name".r.string.continue want. thats usual way you're doing localization in android. id provides multilanguage support automatically based on users system language. have create multiple "values" directories. https://developer.android.com/guide/topics/resources/localization.html provides more information localization.

also can't use "continue" name, use "str_continue" or (it's same "return" or "break" ect.). reserved in java. more information read link: http://java.about.com/od/javasyntax/a/reservedwords.htm

because don't post code of "warningcontinue()", think know has extend "dialoginterface.onclicklistener()". should consider write classes first character uppercase convention reasons, more information read answer on stackoverflow: https://stackoverflow.com/a/414029/2238341


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -