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
New Contributor
abilashn03
Posts: 8
Registered: ‎11-08-2011
My Device: 9800

Problem with listField - simple app

Hello,

 

I am facing a problem when I am trying to pushScreen when a item in the listFiled is pressed. I get java error, "App Error 104 Uncaught:RuntimeException  Scroll for available commands"

int selected = _listField.getSelectedIndex();
ItemInfoScreen screen 	= (ItemInfoScreen) _listScreen.elementAt(selected);
UiApplication.getUiApplication().pushScreen(screen);

 

 

It works fine when I try to remove the MainUIScreen and push the new screen.

int selected = _listField.getSelectedIndex();
ItemInfoScreen screen     = (ItemInfoScreen) _listScreen.elementAt(selected);
UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
UiApplication.getUiApplication().pushScreen(screen);

 _listScreen is the vector which holds the references for all the screens which needs to be displaded when perticular list item is pressed.

 

The problem here is that, if I have removed the MainScreenUI, I cannot navigate back to the mainscreen from second screen.

 

Please help me solve this problem or provide me with the better solutuion for this.

 

My requirement is very siple. There will be a list. when any body clicks on any list item it should navigate to perticular screen which has more information about item clicked. when back is pressed. it should navigate back to main screen and user again will able to click on any item again.

 

I am very new blackberry development. Have gone through a lot of tutorials to achive so far. Please help me. I am stuck now.

 

Thanks,

Abilash

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem with listField - simple app

I can't immediately see any reason why popping your current screen will resolve a problem when pushing your new screen.  I suspect the problem is a little more involved that that.

 

However the first thing is you need to find the actual statement that is causing the problem.  By far the easiest way to do this is to run with the debugger connected.  Do this, and the debugger will stop on the failing statement.  From there I suspect problem resolution is easy.

Developer
Shraddha
Posts: 34
Registered: ‎07-25-2008
My Device: Not Specified

Re: Problem with listField - simple app

Yes, exact line which is creating the problem should be known- please do that using debugger as told by Peter_strange

 

Also, i think u've had similar issue before, Have you tried the new runnable thing that i had replied in ur previous post ? Try that option here, incase ur pushscreen is creating this problem

 

your previous similar post

 

New Contributor
abilashn03
Posts: 8
Registered: ‎11-08-2011
My Device: 9800

Re: Problem with listField - simple app

I figured out that the problem was due to "navigationClick(int status, int time)" method being called twice. It was trying to push the already existing screen to the stack again.

 

To resolve this I have put the following condition

 

if(UiApplication.getUiApplication().getActiveScreen() != screen)
			{
				UiApplication.getUiApplication().pushScreen(screen);
			}

 

Its working fine now. But I dont understand why navigationClick() method was called twice with the same selectedIndex.

 

Is it right to go with this fix?

 

Thanks,

Abilash

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem with listField - simple app

Since there is no navigationClick normally associated with a ListField, I suspect this is something you have added. Put a break point in and look at the stack trace to see where each of the method invocations comes from.

 

You might also like to return true from your navigationClick to indicate you have processed it. 

New Contributor
abilashn03
Posts: 8
Registered: ‎11-08-2011
My Device: 9800

Re: Problem with listField - simple app

yes, I am returning the boolean by

 

 return super.navigationClick(status, time);

 

Thanks,

 

New Contributor
abilashn03
Posts: 8
Registered: ‎11-08-2011
My Device: 9800

Re: Problem with listField - simple app

This is the response i am getting when I connect the debugger to the simulator.

 

 

[0.0] AM: Starting ItemsListUI
[0.0] AM: Started ItemsListUI(301)
[0.0] AM: Foreground is set: ItemsListUI(301)
[0.0] ApplicationManagerImpl.setForegroundProcess : calling notifyApplicationSwitch to switch to backgroun[0.0] d: process=net_rim_bb_ribbon_app(132) pid=132
[0.0] ApplicationManagerImpl.setForegroundProcess : calling notifyApplicationSwitch to switch to foregroun[0.0] d: process=ItemsListUI(301) pid=301
[0.0] FocusHistory: Focus lost; App net_rim_bb_ribbon_app; Component net.rim.device.apps.internal.ribbon.l[0.0] auncher.ApplicationAreaGridField
[0.0] FocusHistory: Focus gained; App ItemsListUI; Component net.rim.device.api.ui.component.ListField
[0.0] FocusHistory: Focus lost; App ItemsListUI; Component net.rim.device.api.ui.component.ListField
[0.0] FocusHistory: Focus gained; App ItemsListUI; Component net.rim.device.api.ui.component.RichTextField[0.0]

 

 

How do I get to know from where the method was called?

 

Thanks,

Abilash

 

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem with listField - simple app

Responding to your previous post, rather than return super, if you have processed the navigationClick and no-one else needs to deal with it, you should return true.

 

It appears you have given us the log rather than the stack trace. 

 

If you put a breakpoint in code, there is usually the option to display the stacktrace, in other words, the list of methods that have been called.  So if you had method A, which called method B, which called method C, in the stack trace you would see A, B and C. 

 

Sorry I don't know how to get this in Eclipse, I use the JDE.

 

Have a look for this and if you can't find it in Eclipse, ask someone to tell you.