android - AlertDialog.Builder is undefined -
thought had working error! i'm still new android , can't seem fix issue no matter what. know it's using "new builder(this);". don't know else use, appreciated!
changeday.setonclicklistener(new onclicklistener(){ public void onclick(view v){ alertdialog.builder b = new builder(this); b.settitle("select day"); string[] types = {"1", "2", "3"}; b.setitems(types, new dialoginterface.onclicklistener(){ public void onclick(dialoginterface dialog, int which){ dialog.dismiss(); switch(which){ case 0: day = "1"; break; case 1: day = "2"; break; } } }); } });
your problem in string[]
array, alertdialog.builder setitems
method doesn't take string[]
array parameter, takes int
or charsequence[]
update: second part of answer is, in builder(this) this
refers onclicklistener
, want refer context
of activity
. can simple put following in oncreate()
context myctx = this; //this sets activity myctx
then replace builder(this)
builder(myctx)
. voila!
Comments
Post a Comment