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
Trusted Contributor
coilfyzx
Posts: 204
Registered: ‎07-03-2011
My Device: Torch
Accepted Solution

Is this Possible?

Hi,

 

Is it possible to access the contents of an EditField that was added to a manager like this:

manager.add(new EditField("Enter","")); ?

 

If so, how please?

_______________________________________________________
Never be close-fisted with the knowledge you've received. For if others were the same to you, you would not be painted as the person you are; the flowing definition of you, would be non existent.

You would be meaningless.
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: Is this Possible?

I believe manager.getField() will allow you to do this.

 

Scott

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

Re: Is this Possible?

Assuming you have a reference to the Manager, let us say it is 'manager'.

 

int fields = manager.getFieldCount();

for ( int i = 0; i < fields ; i++ ) {

Field f = manager.getField(i);

if ( f instanceof EditField ) {

EditField ef = (EditField) f;

// do what you want with ef

}

}

 

A Manager is just a collection of Fields (which could also be Managers, containing Fields and so on).  You can iterate through these Fields as shown. 

 

Note: Code never tested or even compiled.  Not warranted for purpose, use at own risk etc etc. But you get the idea. 

Trusted Contributor
coilfyzx
Posts: 204
Registered: ‎07-03-2011
My Device: Torch

Re: Is this Possible?

Thanks again.
_______________________________________________________
Never be close-fisted with the knowledge you've received. For if others were the same to you, you would not be painted as the person you are; the flowing definition of you, would be non existent.

You would be meaningless.
Trusted Contributor
coilfyzx
Posts: 204
Registered: ‎07-03-2011
My Device: Torch

Re: Is this Possible?

Oh I forgot...How do you check if 'f' the field is an instance of an EditField?
_______________________________________________________
Never be close-fisted with the knowledge you've received. For if others were the same to you, you would not be painted as the person you are; the flowing definition of you, would be non existent.

You would be meaningless.
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Is this Possible?

Code already does that doesn't it?

 

"if ( f instanceof EditField ) {"

Trusted Contributor
coilfyzx
Posts: 204
Registered: ‎07-03-2011
My Device: Torch

Re: Is this Possible?

Ok thanks. Should I be getting a cast exception for this line?

EditField ef = (EditField) f;
_______________________________________________________
Never be close-fisted with the knowledge you've received. For if others were the same to you, you would not be painted as the person you are; the flowing definition of you, would be non existent.

You would be meaningless.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Is this Possible?

Not if you know for sure that f is instance of EditField (meaning, inside "then" clause of the aforementioned 'if').

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!