Thank you for visiting the BlackBerry Support Community Forums.
BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)
BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.
"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."
- Kevin Michaluk, Founder, CrackBerry.com
Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.
07-17-2012 08:59 AM
I have an app where I also add ObjectChoiceFields at runtime with a loop. In my case, I save them in a Vector to reference them later. But you could also ask the their manager for them.
If you place all your choice fields within the same Manager, try using Manager.getField(int i) to retrieve them.
I hope that helps.
07-18-2012 03:22 AM
07-18-2012 04:44 AM
Can you explain your problem another way? Is the problem with detecting the selected item on the ObjectChoiceField or is it persisting the selected item?
If you have a problem persisting values, then can I recommend that you search the forum for information, there are a couple of KB articles and/or labs that discuss this.
07-18-2012 05:24 AM
I am adding ObjectchoiceFields at runtime. I want addition of selected values in ObjectchoiceFields (suppose 3 ObjectchoiceFields are added at runtime) should not be greater than 10.
Here is my code:
public void fieldChanged(Field field, int context)
if(field == combo)
Object ob = combo.getChoice(combo.getSelectedIndex());
String selectedValue = ob.toString();
int select = Integer.parseInt(selectedValue);
sum = sum+select;
if(sum > 10)
sum = sum-select;
07-18-2012 09:03 AM
07-18-2012 10:06 AM
"In such case it goes inide if(sum>10) loop,then sum becomes 7 again and it shows dialog.
Later i select 1st combo and i select value 5 then in such case sum should be 9,bt in my code sum becomes 12."
But 7 plus 5 is 12, not 9. Why should it be 9?
07-18-2012 10:28 AM
07-18-2012 10:49 AM
As peter suggested, you should check some KB articles and labs about persistance values.
You could compute the sum every time instead of accumulate it with the method I suggested before, so you have the last value of every choice. Also, you could save in another object the values as they vary to modify only the latest change.
Anyway, I believe the question is getting out of scope here and we are solving more a logical problem than an ObjectChoiceField problem.
Either you compute the sum starting from zero every time a choice is changed or you save somewhere (in memory, a specific object, int, Vector, persistance, database, whatever) the values of all choices so you can do something like sum-oldValue+newValue.
Think about how would you solve it if instead of ObjectChoiceField you were using just regular integers. If you changed them from time to time, how will you update the total sum of them? That will lead you to solve the problem, I think.