11-28-2012 03:26 AM
Hi
When I am adding a new mainscreen object as a child of the delegateManager of another MainScreen it gives exception.
Since we know that :
Any object of type Field can be added to a manager, including other managers and screens.If a manager or a screen is added to the current manager of a screen, they become child objects and behave as any other field.
So when I tried to add a new MainScreen() object as a child of the current MainScreen, it gives exception.
Yes I can do pushScreen() but that will be like replacement of current Screen. Actually I need to add new MainScreen object with in the current MainScreen.
MyMainScreen :
public class MyMainScreen extends MainScreen implements FieldChangeListener
{
private ButtonField btnField = null;
private NewChildScreen testScreen = null;
public MyMainScreen()
{
btnField = new ButtonField("Hello", ButtonField.CONSUME_CLICK | ButtonField.USE_ALL_WIDTH
| ButtonField.FIELD_HCENTER);
btnField.setMargin(10, 0, 10, 10);
testScreen = new NewChildScreen();
add(btnField);
btnField.setChangeListener(this);
}
protected boolean onSavePrompt()
{
return true;
}
protected boolean navigationClick(int status, int time)
{
fieldChangeNotify(11);
return true;
}
public void fieldChanged(Field field, int context)
{
if (field == btnField)
{
try
{
add(testScreen);
}
catch (Exception e)
{
Dialog.alert("Exception : "+e.getMessage());
}
}
}
}
NewChildScreen:
public class NewChildScreen extends MainScreen
{
private ButtonField button = null;
public NewChildScreen()
{
super(USE_ALL_HEIGHT | USE_ALL_WIDTH);
setTitle("New Screen");
getMainManager().setBackground(BackgroundFactory.c reateSolidBackground(Color.BLUEVIOLET));
button =new ButtonField("New Button", ButtonField.FIELD_HCENTER);
add(button);
}
}
Is there any mistake I am committing while implementation.
I have been trying to implement this but not succeeded yet. I also searched forum but didn't got much help about my problem.
Please help.
11-28-2012 04:23 AM
11-28-2012 04:29 AM
Unfortunately I believe this statement to incorrect:
Any object of type Field can be added to a manager, including other managers and screens If a manager or a screen is added to the current manager of a screen, they become child objects and behave as any other field.
The base of any Manager/Field hierarchy is a Screen, and it is my understanding that the BlackBerry will not accept anything for display that is not a screen and will not allow you to add a Screen to and Manager.
This is not actually a restriction, since in fact every Screen has a base Manager associated with it. If you wanted to move the contents of one Screen to another, you would just copy the contents of this Manager to another Manager (making sure to delete them from the original Manager first of course).
I appreciate that this is not truly reflected in the way the classes are organized.
11-30-2012 12:49 AM
Thanks simon sir and peter sir
Sir I was trying to implement tabbed screen, that's why I was doing this.
There is an another way to implement tabs(using VerticalFieldManagers) that i did followed already.
I was trying to follow the above statement given in following BB article:
http://www.blackberry.com/knowledgecenterpublic/li
Main concern was: will using Managers for creating tabs not create any problem in focus transfer between fields and click events on each field.
I am doing it will tell u if got any problem.
11-30-2012 03:33 AM