java - Illegal state exception :Field added to a manager while it is already parented -
i'm getting exception illegalstateexception :
field added manager while parented
when call below function second time,when changing value of spinner , function called second time, getting illegal state exception.
here code :
void showspinnerdialog(int type) { if (_customspinnerpopup == null) { _customspinnerpopup = new customspinnerpopup(); } uiapplication.getuiapplication().pushmodalscreen(_customspinnerpopup); if (_customspinnerpopup.isset()) { string choice = _customspinnerpopup.getchoice(); _editfieldspinbox.settext(choice); getalbumsforlanguage(choice); } } private void getalbumsforlanguage(string choice) { language = choice; fieldmanager.deleteall(); final richlist list = new richlist(fieldmanager, true, 2, 1); songitemslist = new vector(); songitemslist = serverapi.getnewsongsforlanguage(language, null); (int = 0; < songitemslist.size(); i++) { songitem songitem = (songitem) songitemslist.elementat(i); list.add(new object[] { bitmap1, songitem.getname(), "artist:" + songitem.getartist(), "movie: " + songitem.getmovie() }); } add(fieldmanager);// **here getting exception** list.setfocuspolicy(tablecontroller.row_focus); list.setcommand(new command(new commandhandler() { public void execute(readonlycommandmetadata metadata, object object) { songitem song = (songitem) songitemslist.elementat(list.getfocusrow()); dialog.alert("exe !" + song.getname());
as exception message suggests, cannot add field or manager (which field) container, more once, unless remove first. when call getalbumsforlanguage() second time, call this:
add(fieldmanager);// **here getting exception** a second time, illegal. solve this, surround line with:
if (fieldmanager.getmanager() == null) { add(fieldmanager); }
Comments
Post a Comment