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[]

check here - http://developer.android.com/reference/android/app/alertdialog.builder.html#setitems(int, android.content.dialoginterface.onclicklistener)

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

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -