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
Developer
Posts: 950
Registered: ‎06-22-2010
My Device: 9550
Accepted Solution

ChoiceField Select Event

How can i go to another Screen on selecting the item from Dropdownlist.

What is the interface which should i implements

and what is the Method should i use.

Developer
Posts: 106
Registered: ‎06-18-2009
My Device: Bold

Re: ChoiceField Select Event

 

You need to set the FieldChangeListener of the ChoiceField. This will notify you whenever the value of the ChoiceField changes.

 

You need to implement the FieldChangeListener interface and its fieldChanged method.

 

 

	public void fieldChanged(Field field, int context)
	{
		if (context == FieldChangeListener.PROGRAMMATIC)
			return;

		if (field == YourChoiceField)
		{
                     // add some code here to check the value of the ChoiceField and then push the new screen
		}
	}

 

 

----
If this helped you, press the thumbs up button (on the far right - '+' thumb icon)
If this post solved the issue, click "Accept as Solution"
Developer
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: ChoiceField Select Event

But I am not getting that,

That item we are selecting, How to get that item in the String Object.

I am getting only Index of that value.

Developer
Posts: 588
Registered: ‎05-29-2009
My Device: 9100

Re: ChoiceField Select Event

getChoice(getSelectedIndex())

Developer
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: ChoiceField Select Event

U Suggest me that

getChoice(getSelectedIndex());

But this is not Working.

 

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

Re: ChoiceField Select Event

How is it 'not working'?  In other words, can you explain what you see and what you mean by 'not working'. 

Developer
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: ChoiceField Select Event

I Mean It gives the Error when Building

 

The Error is Below.

 

E:\Nitin\BlackBerry\sample\Combo\Combo\Main.java:49: cannot find symbol
symbol  : method getSelectedIndex()
location: class Combo.Main
            String str=cf.getChoice(getSelectedIndex());
                                    ^
1 error
Developer
Posts: 106
Registered: ‎06-18-2009
My Device: Bold

Re: ChoiceField Select Event

 

In your case it would be of course getSelectedIndex of the cf field.

 

String str= (String) cf.getChoice(cf.getSelectedIndex());

 

This should work.

----
If this helped you, press the thumbs up button (on the far right - '+' thumb icon)
If this post solved the issue, click "Accept as Solution"
Developer
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: ChoiceField Select Event


Thank u Very Much u All.

Thank u Once Again.