Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
VimalSandy
Posts: 97
Registered: ‎07-12-2011
My Device: curve 8900

problem to pop the popupscreen

hi.. i have problem to pop the popupscreen.. im using custom popup screen in that i added radiobutton. when i select the readio button .. popupscreen have to close and bring custom dialog box.. but im not able close the popup screen.. this is my code

 

class AlertDialogboxeditgroup extends PopupScreen implements FieldChangeListener
{


public static AlertDialogboxeditgroup popupScreen = null;

Screen _filescreen;


RadioButtonGroup rbg;
AlertDialogboxeditgroup()
{
super(new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL | VerticalFieldManager.VERTICAL_SCROLLBAR));
this.add(new LabelField("Select the Group",LabelField.FIELD_HCENTER));

popupScreen = this;

final String[] groups = Grouplist.g.getgroupnames();

rbg = new RadioButtonGroup();
rbg.setChangeListener(this);

for(int i = 0; i< groups.length; i++)
{
RadioButtonField groupname = new RadioButtonField(groups[i],rbg,false);
this.add(groupname);
groupname.setChangeListener(this);
}

 


//okButton = new PopiButtonField("Add New Group", Field.FIELD_HCENTER);
// okButton.setChangeListener(this);

 

 

 


//this.add(okButton);

 

 

 


}
public boolean onSavePrompt()
{
return true;
}
public boolean onClose() {

System.out.println("close pop");
Ui.getUiEngine().popScreen(this);
return super.onClose();
}

public void fieldChanged(Field field, int context) {

 

Ui.getUiEngine().popScreen(popupScreen);                                /// i got error in  thisline.IllegalArgumentException is coming


if(field.getClass().toString().endsWith("RadioButtonField"))
{
RadioButtonField rbf = (RadioButtonField)field;



if (rbf.isSelected())
{

String grouplabel = rbf.getLabel();

System.out.println("grouplabel "+grouplabel);

String choices[] = {"Ok","Cancel"};
int values[] = {Dialog.OK,Dialog.CANCEL};

final PopiDialog editGroupDilag = new PopiDialog("Edit GroupName ",choices,values,"GroupName");



editGroupDilag.setPinFieldText(grouplabel);

final String groupname = grouplabel;

UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {



int iResponse = editGroupDilag.doModal();
if(iResponse == 0) { System.out.println("OK Pressed");

 

 


String newgroupname = editGroupDilag.getPinFieldText().toString();

 


}
else { System.out.println("Cancel Presses");



}

}

 


});



}





}

 

}
}

Please use plain text.
Developer
simon_hain
Posts: 16,134
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: problem to pop the popupscreen

calling close() should be enough to undisplay the screen.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Regular Contributor
VimalSandy
Posts: 97
Registered: ‎07-12-2011
My Device: curve 8900

Re: problem to pop the popupscreen

u mean onclose method..
Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: problem to pop the popupscreen

No he means close().  Not sure why you pop the screen in onClose(), Where did you get the idea you needed to do that?  And why do you override onClose anyway?

Please use plain text.
Regular Contributor
VimalSandy
Posts: 97
Registered: ‎07-12-2011
My Device: curve 8900

Re: problem to pop the popupscreen

No peter, im using onclose() for pop the screen.. actually i want pop the popup screen when i select the radio button in that popup screen.. but it showing exception.. i used Ui.getUiEngine().popScreen(popupScreen); and UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen()); both method to close.. but 2nd method close the background screen not the current displaying popup screen..
Please use plain text.
Developer
simon_hain
Posts: 16,134
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: problem to pop the popupscreen

this article should clarify some things for you:
http://supportforums.blackberry.com/t5/Java-Development/MainScreen-explained/ta-p/606644

yes, it says mainscreen, but a popupscreen is also a screen and has many of the same functionalities.

do not overwrite onClose unless you want to do something specific there.

you can just call close() to close the screen.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: problem to pop the popupscreen

I suspect this is because you should not try to pop the screen in the onClose like you are doing.  Why not just close it using close()? 

 

Like I said, doing what you are doing in onClose seems wrong.  Where did you get the idea you needed to do it in there?

Please use plain text.
Regular Contributor
VimalSandy
Posts: 97
Registered: ‎07-12-2011
My Device: curve 8900

Re: problem to pop the popupscreen

can u give me some Snippet.. i used close() method also.. but it shows exception.. i use the onclose() for user click the Escape key.. popup screen i ll close.. that working very fine.. check out fieldChanged method.. there i want to close the screen
Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: problem to pop the popupscreen

A snippet.  OK

 

close();

 

:smileyhappy:

 

Basiclaly remove all the code you have in there that is trying to close the screen, and whereever you want to close the screen, call the screen's close() method. 

 

See how that goes for you. 

 

Actually I think you need to review the article Simon has pointed you at and think about the event syou are trying to detect and react to.  There is code in your sample that indicates you are not that familiar with this sort of stuff for example:

 

Ui.getUiEngine().popScreen(popupScreen);

would be more normally coded as

UiApplication.getUiApplication().popScreen(popupScreen);

 

I don't think you should use the

Ui.getUiEngine()

construct except in background non Ui Applications. 

 

Also

 

if(field.getClass().toString().endsWith("RadioButtonField"))

woudl be usually be coded as

if(field instanceof RadioButtonField)

 

Also, I have no idea what this is trying to do :

 

UiApplication.getUiApplication().invokeLater(new Runnable() {....

 

So think about this some more, start simple, and build until it breaks, so you know where it has broken. 

Please use plain text.