12-14-2010 01:52 PM
tx for your replay. I think, i am getting closer...
No w i am getting error on
this == tabArea.getManager();
I tried with
this.getManager() == tabArea.getManager();
I am still getting error....i know this should be easy to do.....but i am not getting this??
could you suggest me anything??
Could post the link of the delete manager documentation please??
12-14-2010 02:08 PM
Oh, I see you've skipped an important step or two in your BlackBerry programming:
Here is the link (it is for the latest, 6.0.0 API, but Manager.delete() and Field.getManager() did not change much in the last... forever) - make sure you check the API documentation before asking questions here:
I tend to have this page open in a separate tab at work at all times - it's that important!
There is a sticky thread in this forum with useful links for novice and experienced programmers alike - check that, too.
After you've done some studying, remember that you can search the forums before posting your question - I've found enough useful information that way.
By the way, this getManager() is logically wrong - you want to compare the tabArea's manager to this because it is the manager which is trying to delete tabArea.
12-14-2010 02:23 PM - edited 12-14-2010 02:31 PM
tx for the quick response,
i understood that....
when we say this .... we refrerring to the screen below manager right?
this (MainScreen) == tabArea.getManger() (Manager) so ....I am getting incomparable type error....
12-14-2010 02:43 PM
Oops... if this is a Screen, you need to compare like this:
getDelegate() == tabArea.getManager() // (in case of FullScreen and other Screens)
or this:
getMainManager() == tabArea.getManager() // (in case of MainScreen)
You could also do the whole thing this way:
try {
delete(tabArea);
} catch (Exception e) {
// might want to report it - System.out.println(e.toString() + " trying to switch tabs");
}
tabArea = ...;
add(tabArea);
12-15-2010 10:53 AM
Thank you for your reply...
but it's still throwing the exception when i try to delete the tab area...
public void Refresh()
{
final VerticalFieldManager newTab = displayTab2();
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
if(tabArea != null && tabArea.getManager() == getMainManager())
{
delete(tabArea); ////exception
}
tabArea = newTab;
add(tabArea);
}
});
}
12-15-2010 11:27 AM
Next time please quote the text of exception - it'll save the questions here.
Anyway, this should work no matter what:
Manager m;
if (tabArea != null && (m = tabArea.getManager()) != null) {
m.delete(tabArea);
}
...
12-15-2010 12:42 PM
tx ....but i m still getting the following exception....
could you tell me y?
Uncaught exception thrown - IllegalArgumentException
public void Refresh()
{
final VerticalFieldManager newTab = displayTab2();
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
Manager m;
if (tabArea != null && (m = tabArea.getManager()) != null)
{
m.delete(tabArea); //here its happens tabArea --> illegalArgument
tabArea = newTab;
m.add(tabArea);
}
}
});
}
12-15-2010 02:03 PM
Well,
people here are volunteers and cannot debug the code for you. When you get an exception, investigate more before posting. Debugger shows the actual classes of involved objects; you can check whether anything is null, look inside the objects at the private members, compare, analyze and think.
We are not at your keyboard watching over your shoulder - do your homework, read the documentation and think, think, think!
Only you can check what tabArea or m is, find its manager and, if necessary, its Manager's manager and what their Classes actually are. Do that, dig more, train yourself to use the debugger - you must have this skill to become successful at software development.
By the way, your code now is wrong - tabArea = newTab; and add(tabArea); (not m.add(tabArea)!) should happen outside (after) that if (tabArea != null...).
12-16-2010 04:07 AM
sometimes it is best to step a bit back from the code and try to visualize what it does. maybe draw something on a sheet of paper, like the structure of managers you are building.
it also helps if you give your fields self-speaking names, with "m" you will not go far. always write code with the possibility in mind that somebody else may want to check/change/view it. this includes comments, but also a self-explaining code.
when you come back to your project after a few months to do some bugfixes or add some features you will be thankful for your efforts.
and, as a plus, it also helps with your current problem.
in university we spent 4 days analyzing, drawing UML etc, then one day implementing it.