If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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 Developer
Sultan14
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930
My Carrier: Tmobile
Accepted Solution

How to make ListStyleButtonField work!

Hello,

I have a question about the ListStyleButtonField. How can I make each field in the list go to a spicific screen class?

 

ListStyleButtonField firstField =

new ListStyleButtonField( button1left, "Customer", buttonRight, 0);

firstField.setChangeListener(

this);

 

add( firstField );

 

ListStyleButtonField secondField =

new ListStyleButtonField( button2left, " Contract", buttonRight,0);

add( secondField );

Please use plain text.
Developer
simon_hain
Posts: 15,900
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to make ListStyleButtonField work!

as this is not in the API you should link to the source:
http://supportforums.blackberry.com/t5/Java-Development/Implement-advanced-buttons-fields-and-manage...

or directly
https://github.com/blackberry/Samples-for-Java/blob/master/Advanced%20UI/src/com/samples/toolkit/ui/...

as you can see in the sourcecode, all actions invoke a fieldchange event. this can be captured with a fieldchangelistener, which you only add for the first field (maybe you obmitted the second).

if you implement fieldchanged in your mainscreen you have to discern from where the event comes. to do that, declare the fields on the screen scope and check if the field paramater of the fieldchanged method is the field you need.

example:
public void fieldChanged(Field field, int context) {
if (context != FieldChangeListener.PROGRAMMATIC) {
if (field == okButton) {
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Developer
Sultan14
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930
My Carrier: Tmobile

Re: How to make ListStyleButtonField work!

Thank you Simon for the Quick reply. But what do you mean by okButton, as you can see I'm not using a buttons with this list. I already added some buttons and it worked for me. So in my code does okButton = something like firstField. And i'm sorry to bothering you. But as you know i just start wit the BB development so I hope you tolerate me. Thanks!
Please use plain text.
Developer
simon_hain
Posts: 15,900
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to make ListStyleButtonField work!

your buttons are called firstField and secondField.
The example was just that, an example, i did not adjust it to match your code, so you have to do a little bit of transfer on your own.

Also change this line
ListStyleButtonField firstField =
to
firstField =

and fix the now occuring error by decalring the field on the screen scope.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Developer
Sultan14
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930
My Carrier: Tmobile

Re: How to make ListStyleButtonField work!

that's the screen i'm working with

 

 

// this is my constructor

public

LoginSuccessScreen(String username, String domain){

.....

Bitmap buttonRight = Bitmap.getBitmapResource(

"right.png" );

ListStyleButtonField firstField =

new ListStyleButtonField( button1left, "Customer ", buttonRight, 1 );

add( firstField );

 

//that is the field changed method

public

void fieldChanged(Field field, int context) {

 

// TODO Auto-generated method stubif (context != FieldChangeListener.PROGRAMMATIC) {

 

if (field == ??) {

UiApplication.getUiApplication().pushScreen(

newAlbum());

}

}

}

 

Please use plain text.
New Developer
Sultan14
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930
My Carrier: Tmobile

Re: How to make ListStyleButtonField work!

so I should declare the firstField and the secondField in the Class so I can use it in the methods, right?

Please use plain text.
New Developer
Sultan14
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930
My Carrier: Tmobile

Re: How to make ListStyleButtonField work!

I did it like that but it still not working :smileysad:

 

publicvoid fieldChanged(Field field, intcontext) {

 

// TODO Auto-generated method stubif (context != FieldChangeListener.PROGRAMMATIC) {

 

if (field ==firstField) {

UiApplication.getUiApplication().pushScreen(

newAlbum());

}

}

}

Please use plain text.
Developer
rabiray
Posts: 141
Registered: ‎07-13-2011
My Device: BB Bold
My Carrier: Vodafone

Re: How to make ListStyleButtonField work!

Hi,

 

I dont know if I am right...but

 

Is ur class implementing FieldChangeListner and  have u add this listner to ur buttons.

 

Class implements FieldChangeListner

 

firstField.setChnageListner(this);

secondField.setChnageListner(this);

 

Thx

Rabi

 

 

Please use plain text.
Developer
simon_hain
Posts: 15,900
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to make ListStyleButtonField work!

what exactly is "not working"?
the code looks ok, if you can compile it it should work as intended and push a new Album screen.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Developer
Sultan14
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930
My Carrier: Tmobile

Re: How to make ListStyleButtonField work!

Thank you so much Simon, sorry for making you angry :smileywink:.
It works now!
Please use plain text.