ObjectChoiceField and ChoiceField$ ChangeOptionChoiceField classcastexception
one line in fieldchangelistener of my ObjectChoiceField, I have this line:
choice final int = (field) .getSelectedIndex ((ObjectChoiceField));
but he gives this exception:
ClassCastException: Cannot mount net.rim.device.api.ui.component.ChoiceField$ ChangeOptionChoiceField (id = 91958272) at net.rim.device.api.ui.component.ObjectChoiceField
How can I me index newly selected of the ObjectChoiceField in the Interior of the listener?
I tried to use a final ObjectChoiceField so I could access it just inside the listener, but it I still get the value of previous for the selected index.
my code:
final distance ObjectChoiceField = new ObjectChoiceField ("Menu choose:", menu list);
If (menuList.length > 1) {}
Dialog.Alert ("length =" + menuList.Length);
Flash = Integer.ToString (menu list [Dialog.ask ("which menu?", menuList, 0 "")] .getValue ());
Dialog.Alert ("Flash =" + Flash);
distance.setChangeListener (new FieldChangeListener () {}
' Public Sub fieldChanged (field field, int context) {}
choice final int = (field) .getSelectedIndex ((ObjectChoiceField));
Dialog.Alert ("get next choice");
final int choice = distance.getSelectedIndex ();
Dialog.Alert ("location =" + choices);
Field.Get
final int ctx = context;
New Thread() {}
public void run() {}
loadMenus (ctx, choice);
}
}. start();
}
});
objectSymbol = new ObjectChoiceField ("", ARRAY, 0, Field.FIELD_LEFT)
{
protected void fieldChangeNotify (int context)
{
indexCurrency = getSelectedIndex();
}
};
Tags: BlackBerry Developers
Similar Questions
-
Strange: Objectchoicefield and ObjectListField in Gridfieldmanager - navigation problem
Hi @all,
I have a very strange problem, because running Simulator runs as I would have liked, but the device, the navigation is bad:
running OS 5.0.0.42 3 on device (BB9700) and the Simulator
1. the building screen
2. put verticalfieldmanager on it that contains the background image
3. put gridscreenmanager (with a column - the problem is with more then one column, too) on the first position of the vfm
4. turn objectchoicefield with 5 points on the 1st row of the gsm
5. put the objectlistfield with 5 points on the second line of gsm
Program running in the Simulator:
View all as I prefer.
The first objectchoicefield and beyond the objectlistfield.
When I scroll with trackpad OCF Gets the focus first and after that the olf on its first line.
I can scroll up and down, and everything's fine.
Program running on the device:
View all as I prefer.
The first objectchoicefield and beyond the objectlistfield.
When I scroll with trackpad OCF Gets the focus first and after that the olf on its first line.
So far so good:
When I scroll down to the olf, all things are working properly. For example, point 4 a now focus.
Now, if I try to go back in the OLF, it should go back to article 3 of the olf, but this is the leap into objectchoicefield. After that, if I try to go back to the objectlistfield, it jumps directly to point 4, which he came before.
If I don't put the objectchoicefield in the first row, everything works fine.
What can I do?
I did something wrong?
All ideas are very appeciated.
Thanks in advance.
CUA
Michael
Well, I found it.
I made a mistake in the application of my own gridfieldmanager navigationmovement method.
What is already strange: I used the same gridfieldmanager within 2 screens in my application. First screen was working fine, the second one was bad. Same content in both screens.
Sorry for that.
Thank you for all.
CUA
Michael
-
ObjectChoiceField and FieldChangeListener
I'm creating an application (Storm 9530 component package 4.7) that uses an ObjectChoiceField which is filled by anywhere from 1 to 50 choice programming. I would use the FieldChangeListener to generate a new pop-up screen based on the selection made by the user of the ObjectChoiceField. Because the list can be quite long, the user may need to scroll the list to find their choice. Each time the selection is changed in the FieldChangedListener is called, but I want only to take action in the final selection is made ("clicked"). I have been in charge of the search and search but have not found the key to understand the current state of the ObjectChoiceField (open or closed). Any help would be greatly appreciated.
TIA,
Tim
You will not be able to differentiate between these types of changes within a FieldChangeListener. Instead, you might have the user selects an entry and use a ButtonField or MenuItem to check their choice. Or you could have your action occur when the focus is moved out of the ObjectChoiceField.
-
Selection of savings between ObjectChoiceField and Hashtable
I managed to save a text using EditField
{if (profile1Hashtable.ContainsKey ("LastName"))}
lastName.setText ((String) profile1Hashtable.get ("LastName"));
}
So I thought that to save a value (sex selector) would be
{if (profile1Hashtable.ContainsKey ("Sex"))}
sexChoiceField.setSelectedIndex ((Integer) profile1Hashtable.get ("Sex"));
}
But what is the code that I put in the save()?
Its because I failed at the bis code 'new '. Here's a corrected line:
profile1Hashtable.put ("Sex", New Integer (sexChoiceField.getSelectedIndex ()));
-
Characters.Escape and ObjectChoiceField
Hi all
I made an app that has an ObjectChoiceField and when you select an index, she throws you to another screen filtering what you see according to the selected index.
When you are in the new screen and the user, press the ESC key to go back, the ObjectChoiceField displays the index that the user has selected before, and I want the ObjectChoiceField to set the default index value, is it possible?
Not convinced this Sad_Bird idea is very "as object". I don't think you want 2 screen to worry about screen 1.
A number of options come to mind, the manifesto being once you got the selected index and screen 2, then in Screen1, just created all the index selected in your ObjectChoiceField to 0. You can do so after you press display 2.
-
Hi here is my problem
I've created a subclass (DynamicObjectChoice) that extends ObjectChoiceField and created an another subclass (MyObjectChoiceListener) that extends FieldChangeListener.
In DynamicObjectChoice I crushed constructor and take an int parameter.
Then in my main class, I've created a DynamicObjectChoice and fill in a loop like this.
for (int i = 0; i < someInt; i++) { choiceFieldArray[i] = new DynamicObjectChoiceField(Label, choices, 0, i); MyObjectChoiceListener listener= new MyObjectChoiceListener(); choiceFieldArray[i].setChangeListener(listener); add(choiceFieldArray[i]);}
and crushed fieldChange MyObjectChoiceListener with this method.
public void fieldChanged(Field field, int context) { System.out.println((DynamicObjectChoiceField)field).getLabel()); }
AND HE SAID CLASSCASTEXCEPTION! Why? im stuck here. I have founfd that I have change
System.out.println((DynamicObjectChoiceField)field).getLabel());
TO
System.out.println((ChoiceField)field).getLabel());
It works but I need other methods that are available only on DynamicObjectChoiceField. Help, please!
I solved this problem, but I don't understand why I should use it. I think that the event 'clone' the field being passed at run time, and when you try to cast it giives you classcast exception. Solution was this:
((DynamicObjectChoiceField) field.getOriginal()).getLabel();
So in the hope that it helps someone else.
-
Open objectChoiceField press ENTER, curve 8520 (JDE 5.0)
Hello
I added an objectChoiceField on horizontalfieldManager (hfm) and hfm is added to the main vericalfieldmanager.
I click the trackpad, opens my objectChoiceField and I am able to make the selection,
but when I press on enter (when ojectchoicefield is focused), the focus moves to the next field. I want to open choicefield when I press on enter the update choicefield.
Thanks in advance.
Thank you and best regards,
Fekri
I created this example... try what he's working on the press to enter the key
SerializableAttribute public class HelloWorldScreen extends form {}
ObjectChoiceField objectChoiceField;
public HelloWorldScreen()
{
setTitle ("Screen Test");objectChoiceField = new ObjectChoiceField ("Test", new String [] {"1", "2", "3"});
Add (objectChoiceField);}
{} protected Boolean keyChar (char c, int status, int time)
If (getFieldWithFocus () == objectChoiceField & c == Characters.ENTER) {}
EventInjector.invokeEvent (new EventInjector.NavigationEvent (EventInjector.NavigationEvent.NAVIGATION_UNCLICK, 0, 0, status))));
}
Returns true;
}}
-
Hai all,
I need to implement the button and label field of objectchoice with separate click to button and label (or listview complete) event, please give suggestions to implement the custom objectchoicefield.The name of the company must establish a click event to view the details and the distinct x (delete button) need separate, click event to remove the choice of listfield.
Thank you.
You ask a lot of us aren't you?
I suggest you just start trying to do just one of these things, something code that you think the work and we could help you get the code works.
But I must point out that I've never seen anything like that on the BlackBerry that works as an ObjectChoiceField and is the kind of thing you're after. So I suspect that you maybe isn't able to implement features as requested, or if you can, it will take a lot of time. You might think to simplify the obligation.
Remember that an ObjectChoiceField is not a click event different for different parts of the drop down, so you won't be able to use it. You need to create something else. In this kind of situation, I have in the past, created a popup screen to display the values of 'pull down', but this clearly does not resemble a pull down, even if it provides the same functionality.
-
No discussion on objectchoicefield
Hello friends
I created 4 objectchoicefields and added to the screen. Now when I move the trackball, I can't focus on the fields. the focus remains on the raw itself.
When I looked at the API documentation, he said "If you want your field receives focus, then you must override isFocusable to return true.
So I created the objectchoicefield like this.
showDialogTime = new ObjectChoiceField("Alerts Displayed For ",choiceNumbers,getTimeByInteger(),Field.FOCUSABLE) { public boolean isFocusable() { return true; } protected void fieldChangeNotify(int context) { if(context==2) { ApplicationSettings.getInstance().setStatusAlertTime(getIntFromString()); } } public void paint(Graphics graphics) { graphics.setColor(Constants.fontColor); super.paint(graphics); } };
but I still can't s focus.what the problem?
Thank you... But I got it working as there was a mistake in my code... I overrided navigationmovement() and consume it the movement of the trackball. Sorry to bother guys. Thanks again
-
How to re - initialize an ObjectChoiceField.
I usually Initializes an ObjectChoiceField like this:
String [] message = GetMessageList();
cboMessages = new ObjectChoiceField ("select a message," messages ");Add (cboPrinters);
And it works very well. However, later I want to delete all the entries and add a new list to the ObjectChoiceField.
I can't seem to find how to clear the ObjectChoiceField and I see no way to insert new items?
Am I missing something simple massively?
Thank you.
Try the method of setChoices (choice of Object []) ObjectChoiceField, so in your case, you would say
cboMessages.setChoices (newList);
General, I'm an invalidate() after that I did a setChoices(), just to make sure that the field is being updated on the screen.
-
ChoiceField default value does not match the visible value
I'm creating an ObjectChoiceField and have noticed a strange behavior.
As soon as the application loads I see that choice at index 0 is the selected choice. However, if I call mychoice.getSelectedIndex () returns 1. I even tried to call this.setSelectedIndex (0) in the constructor, but it remains 1. If anyone has experienced this?
NVM. freakin ' getIndex/getSelectedIndex are too similar!
-
"BOLD" of Smartphones blackBerry displays serious error - IllegalArgumentException event log
I was watching the "BOLD" error log and I came across a couple of fields marked "serious error". It seems that it is because of some kind of rendering on a modal dialog box, but I don't know exactly how to read the newspaper very well. Here's the glued log entry. Any ideas?
Name: IllegalArgumentException
GUID: 9c3cd62e3320b498
Time: February 5, 2009 11:26:33
30
net_rim_cldc-10
ObjectChoiceField
getChoice
0x6B9C
net_rim_cldc-9
ChoiceField
0x6FF6
net_rim_cldc-9
ChoiceField
getWidthOfChoice
0x63F2
net_rim_cldc-9
ChoiceField$ ChangeOptionChoiceField
getWidthOfChoice
0x71DF
net_rim_cldc-9
ChoiceField
0x6F3C
net_rim_cldc-9
ChoiceField
moveChoiceFocus
0 x 6498
net_rim_cldc-9
ChoiceField$ ChangeOptionChoiceField
moveFocus
0x73B2
net_rim_cldc-8
Manager
moveFocus
0x4E7C
net_rim_cldc-8
Screen$ NavigationMovementFocusSelector
Select
0xABC3
net_rim_cldc-8
Screen
0xA40D
net_rim_cldc-8
Screen
navigationMovement
0x9AED
net_rim_cldc-8
Screen
dispatchNavigationEvent
0 x 8098
net_rim_cldc-9
UiEngineImpl
processMessage
0x9B41
net_rim_cldc-6
Application
processNextMessage
0xF06
net_rim_cldc-7
ModalEventThread
run
0x43EF
Hello
Outside of a technician certified to the RIM, I know most of the people can read and understand.
I love you feared when I read on the curve and the storm.
Although this indicates a serious error, I have not experienced the loss of function with each device.
Every day I receive a severe message related to Javascript.
I hope this helps!
Thank you
Bifocals
-
Align ButtonField Center in HorizontalFieldManger when ObjectChoceField is not selected
Hello
I have developed a screen in which there's a topic labelField below that there is an ObjectChoiceField... My position and ObjectChoiceField do not scroll and will remain constant, under the title and ChoiceField object I have some data that must be the subject of a scroll and I could achieve this scrolling thing but my problem is that I place a button below these materials and placed this button in HorizontalFieldManager as followsButtonField back;
HorizontalFieldManager But_Back = new HorizontalFieldManager (HorizontalFieldManager.FIELD_HCENTER);
Back = new CustomButtonField ("Back", ButtonField.FIELD_HCENTER);
Back.setChangeListener (this);
But_Back.Add (back);The first problem: At when only the header of the loading of the page and object coice field and my left side coded hard LabelField will be present and the button below and when I select the value in the ObjectChoiceField then the values corresponding to the labelField letside will be displayed all I can attchieve using the fieldChanged but my button that is currently I am unable to put in the Center... that when the page is loaded without values are present, so the button is to the left side and when I select a value of ObjectChoiceField, then it is aligned to the Center, I want to be at the Center...
FYI: in the order of scroll implememtn in my Constructori saySuper (new VerticalFieldManager (), NO_VERTICAL_SCROLL);
Here I put the code for coice position and object fields in two different HorizontalFieldManager and then announces to the screen
For the scrolling now, I create a verticalFieldManger like:
VerticalFieldManager vor = new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL |) VerticalFieldManager.VERTICAL_SCROLLBAR);
and each variable left and right in addition to HorozontalFieldmanger
HFM HorizontalFieldManager = new HorizontalFieldManager();
VFM. Add (HFM);and at the end I say
HorizontalFieldManager But_Back = new HorizontalFieldManager (HorizontalFieldManager.FIELD_HCENTER);
Back = new CustomButtonField ("Back", ButtonField.FIELD_HCENTER);
Back.setChangeListener (this);
But_Back.Add (back);
VFM. Add (But_Back);
Add (VFM);Add Field.USE_ALL_WIDTH in your VerticalFieldManager and DrawStyle.HCENTER in your ButtonField.
Something like:
VerticalFieldManager vfm = new VerticalFieldManager(Field.USE_ALL_WIDTH | VerticalFieldManager.VERTICAL_SCROLL | VerticalFieldManager.VERTICAL_SCROLLBAR); /// /// HorizontalFieldManager But_Back = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER); ButtonField Back = new ButtonField("Back",DrawStyle.HCENTER); Back.setChangeListener(this); But_Back.add(Back); vfm.add(But_Back); add(vfm);
Concerning
Bika
-
a simple form with the "submit" button: can it look better?
Hi all
I did not imagine that a simple form (with Textfields and ChoiceFields) could do a lot of problems:
I would like to ask a few basic questions about it. First the code (Simplified):
GridFieldManager formfm; EditField surname = new EditField("", "-", 25, Field.FIELD_LEFT | Field.FIELD_VCENTER | EditField.FILTER_DEFAULT); EditField email = new EditField("", "-", 25, Field.FIELD_LEFT | Field.FIELD_VCENTER | EditField.FILTER_EMAIL); public FormFieldManager(){ formfm = new GridFieldManager(2,0); formfm.add(new LabelField("who: ", Field.FIELD_RIGHT | Field.FIELD_VCENTER)); String[] choicewho = new String[] { "Mr", "Mrs", "Miss" }; ObjectChoiceField who = new ObjectChoiceField("", choicewho, 0, Field.FIELD_LEFT |Field.FIELD_VCENTER); formfm.add(who); formfm.add(new LabelField("Surname :", Field.FIELD_RIGHT | Field.FIELD_VCENTER)); formfm.add(surname); formfm.add(new LabelField("E-Mail :", Field.FIELD_RIGHT | Field.FIELD_VCENTER)); formfm.add(email); ButtonField sendButton = new ButtonField("Send", Field.FIELD_HCENTER|ButtonField.CONSUME_CLICK); formfm.add(sendButton); FieldChangeListener listenerSendButton = new FieldChangeListener() { public void fieldChanged(Field field, int context) { try { String data = "send=true&surname=" +surname.getText(); data += "&email=" + email.getText(); httpPost("http://bla/sendData.php", data); } catch (IOException e1) { e1.printStackTrace(); } formfm.deleteAll(); formfm.add(new LabelField("Grazie!")); } }; sendButton.setChangeListener(listenerSendButton);
now my questions:
(1) don't miss something (style) for the EditFields? At the present time, it is possible to change them, but the behavior (9700 Simulator) is strange: it is 'difficult' to get from one field to the other and everything moves sometimes when editing...
How do you define a standard form that seems 'normal' and can be completed as expected in other applications? (Swifts nothing, it is possible to access the next field with the expected key / trackpad (I have no touch screen)) and so on?
The EditFields do not even have a border, but I guess that's the standard case on BlackBerry.
(2) the ObjectChoiceField is also very ugly... It's too big... Is it not possible to reduce the size without much effort? (I couldn't everride it correctly). (I also tried with radio buttons, but unfortunately I can't add a RadioButtonGroup to my LayoutManager, strange)
(3) it is perhaps a stupid question: I can't get the text selected from the ObjectChoiceField (to send it can in data).
AM EditField, it's simple:
editfield.getText()
But how is it with my ChoiceField?
I found getSelectedIndex() but it provides a value int not text...
Thanks in advance for any suggestions!
silizia
1. you have defined fields as follows:
EditField family name = new EditField ("vorname:", "-", 20, EditField.FILTER_DEFAULT);
The 20 means 20 characters, so it's all the field allows you to enter.
2. Yes, the mail filter is pretty useless. Use the EmailAddressEditField instead
3. you can play with the scroll, but the best thing to do is to set the focus on the first field that you want people to pull together - usually the upper part of the form.
-
Hello
I worked on an application and I noticed that when I run on my device (8800), in some cases performance is very slow.
I have a lot of choiceFields, and the first time I click on one to change the option, it takes 2-3 seconds to reject the choices menu. The next choiceField I click on works fine, it is still only the first who has the lag.
I noticed the same thing if I invoke the context menu by clicking the blackberry button. When I try to remove the menu, it takes 2-3 seconds, and again once this happens only the first time I click to display the menu. If I try again, without stimulus the app, it's fast and works as expected.
So here something that happens when the small menu disappears which causes a shift of the first time, that he has to go.
My screen consists of the following:
VerticalFieldManager (vertical scrollbar) x 1
Custom Manager (no scrolling) x 1
VerticalFieldManager (no scrolling) x 1
horizontalFieldManager (no scrolling) x 15
RichtextField, x 1, ObjectChoiceField x 1
RichTextField x 1
Any ideas?
Thank you!
Thanks for the link.
It turns out that I have is the substitution of the method onExposed() of the ObjectChoiceField, and went down to the size of the font in this method and for some reason any caused it to slow down. Now, I have just a flag to reset the font size as needed, rather than always doing.
Thanks again!
Maybe you are looking for
-
Can I set up another iTunes account if forget my security question and answer
I forgot my security questions and answers. When I first set up my account. When I try to buy whatever it is on iTunes now on my iPhone 4S. Something appears on the screen. Responds to say I need to get to safety. I don't remember my Email of relief.
-
Satellite Pro L770 - intermittent black screen
I had some problems in the last few weeks with my L770 Pro Satellite. Occasionally, the screen is blank, it comes and goes without apparent cause, it can sometimes be empty for an hour, sometimes more, sometimes much shorter.There is a display when I
-
Card dedicated Y570 GT555 graphic is not recognized
So I have two left, one with windows 8.1 and the other with windows 7 but after upgrade to windows 8.1, I noticed the ability to switch the internal graphics card to the dedicated graphics card (nvidia geforce GT555) came with the laptop, no longer w
-
What method of interpolation using a characteristic diagram?
Hello Does anyone know what interpolation method is used when you create a characteristic diagram (diagram outline 3D) using a triplet of data? Interpolation assumes that the fitted surface passes exactly through the data points. How is the rest of t
-
I've used iTunes until my iPod crashed. Now, I have a Sansa and I would add my music from my Media Player so I can set up my Sansa with my music, but it does not drag-and - drop music into my music folder. Help, please original title: Media Player