android - Trouble setting items in AlertDialog with OnClickListener -
having trouble trying set spinner withing alertdialog, keep getting error "the method setitems(int, dialoginterface.onclicklistener) in type alertdialog.builder not applicable arguments (string[], new view.onclicklistener(){})"
i'm new android programming , still getting used it, appreciated! thanks
alertdialog.builder b = new builder(this); b.settitle("select day"); string[] types = {"1", "2", "3"}; b.setitems(types, new onclicklistener){ public void onclick(dialoginterface dialog, int which){ dialog.dismiss(); switch(which){ case 0: day = "1"; break; case 1: day = "2"; break; } } });
change:
b.setitems(types, new onclicklistener){
to
b.setitems(types, new dialoginterface.onclicklistener){
and have split
string[] types = {"1", "2", "3"};
to individual ints, or charsequence array.
you have onclicklistener normal view in code somewhere, , have in imports. onclicklistener classes share same name, eclipse auto resolves them imported one. can specify parent class in such cases.
additionally, setitems() method eclipse has resolved takes single int first parameter, not string array. use other setitems() method though, takes charsequence array. in such case, change
string[] types = {"1", "2", "3"};
to
charsequence[] types = {"1", "2", "3"};
Comments
Post a Comment