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
Contributor
Posts: 18
Registered: ‎03-02-2012
My Device: BlackBerry 9300
My Carrier: Yoigo
Accepted Solution

Back to screen with reset

Hi people,

 

in my applicaion there are two screens:

-screen A --> a listfield with many checkBox and a button

-screen B

 

Users can select checkboxes and can press a button that call popScreen method with new screen B as argument. When users press escape button in screen B, automatically it returns to screen A with checkboxes already selected. 

My cuestion is, how do i do for back to screen A in her initial state(checkboxes unselected and another cuestions)?

 

I hope that i explained well Smiley Frustrated

 

Thanks in advanced, 

 

regards!! Smiley Happy

 

P.D: sorry for my english 

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Back to screen with reset

easiest way would be to reset the screen after calling push B.
----------------------------------------------------------
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
Contributor
Posts: 18
Registered: ‎03-02-2012
My Device: BlackBerry 9300
My Carrier: Yoigo

Re: Back to screen with reset

Thanks very much.

Yes, that way is correct but what happens if i need information from screen B to update screen A?

 

For example, in screen B user can add an item that I should incorporate to listfield, so I can not update screen A until user press escape key in screen B, is it possible? thanks in advanced

Highlighted
Trusted Contributor
Posts: 146
Registered: ‎03-22-2010
My Device: Not Specified

Re: Back to screen with reset

yes it is possible you can refer your listfield in screen b and add item to it and call invalidate on listfield , this should work

 

pls note invalidate listfield after adding item to it and invoke it on listfield 

 

hope this helps

Developer
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: Back to screen with reset

[ Edited ]

Try like this sample:

 

Sample Screen:

 

public class Def extends MainScreen
{
	public Def() 
	{
		createGUI();
	}
	public void createGUI()
	{
		EditField editField=new EditField("Enter: ", "");
		add(editField);
		
		ButtonField click=new ButtonField("Click", Field.FIELD_HCENTER);
		click.setChangeListener(new FieldChangeListener() 
		{
			public void fieldChanged(Field field, int context) 
			{
				UiApplication.getUiApplication().pushScreen(new SamplePopupScreen(Def.this));
			}			
		});
		add(click);
	}
}

 

and the popupScreen is:

 

public class SamplePopupScreen extends PopupScreen
{
	Def def;
	public SamplePopupScreen(Def def) 
	{
		super(new VerticalFieldManager());
		this.def=def;
		createGUI();		
	}

	private void createGUI() 
	{
		add(new LabelField("Popup Screen",Field.FIELD_HCENTER));
		//Write your code to display on screen;
	}	
	public boolean onClose() 
	{
		def.deleteAll();//These three steps are for reset the screen;
		def.createGUI();
		def.invalidate();
		UiApplication.getUiApplication().popScreen(this);
		return super.onClose();
	}
}

 Enter somthing in edit field and press the click to see the difference that screen is reset or not;

 

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

ALI SHAIK.
Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Back to screen with reset

you can give the information to your new screen directly, either using the constructor or a set method.
afterwards you reset your screen. just take care that you don't put any objects that are modified by the reset (strings are safe).
----------------------------------------------------------
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
Contributor
Posts: 18
Registered: ‎03-02-2012
My Device: BlackBerry 9300
My Carrier: Yoigo

Re: Back to screen with reset

Thanks to all,

I had thought of that solution but I didn't know if it would give me memory problems because i come from java me devices and it always causes problems due to screen A has a lot of elements.

I will try it, thanks very much,

 

regards. 

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Back to screen with reset

please mark the thread as solved
----------------------------------------------------------
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