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

Adobe AIR Development

New Developer
Posts: 21
Registered: ‎04-19-2011
My Device: Blackberry Torch 9800
My Carrier: Rogers

BB10 TextFormat on a SegmentedControl

Wondering if anyone has had any success changing the text format of a SegmentedControl in BB10?  


I have tried the example here but it doesn't seem to work.  Mainly, I am just trying yo change the font color of each item.


Any suggestions appreciated.  Thanks.

Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: BB10 TextFormat on a SegmentedControl

I have not tried, but did you try the CSS method?
New Developer
Posts: 21
Registered: ‎04-19-2011
My Device: Blackberry Torch 9800
My Carrier: Rogers

Re: BB10 TextFormat on a SegmentedControl

I have not tried the CSS method as I am little uncertain how to target the specific elements of the SegmentenControl.  Thanks for the suggestion though, I will look into how to do that.

Posts: 194
Registered: ‎11-12-2010
My Device: Not Specified

Re: BB10 TextFormat on a SegmentedControl

[ Edited ]

To use the setTextFormatForState method, you actually need to override the SegmentedCtrl class. This is a slightly adapted version of what Julian Dolce explained to me when I had the same problem a year ago with the PlayBook:


	import qnx.fuse.ui.buttons.RadioButton;
	import qnx.fuse.ui.buttons.SegmentedControl;
	import qnx.fuse.ui.skins.SkinStates;
	 * Override QNX default formatting for SegmentedCtrl 
	public class MySegmentedCtrl extends SegmentedControl

		private static var counter:int = -1;
		private var id:uint;
		public function MySegmentedCtrl()
			// In order to give each Segmented Control a unique id, 
// keep a running counter and store the current number // for each instance (if you have several controls they
// may all be created, before the first one starts // adding its buttons)
counter++; id = counter; } override protected function onButtonAdded(child : RadioButton) : void { // set button width var dpLength : int = dataProvider.length; child.width = Math.round( width / dpLength ); // set group name (not just any name!
// must be "0SegmentedRadioGroup", "1SegmentedRadioGroup" etc.)
child.groupname = id + "SegmentedRadioGroup"; //Set your formats to whatever you like here. child.setTextFormatForState( MyFormats.UP, SkinStates.UP ); child.setTextFormatForState( MyFormats.SELECTED, SkinStates.DOWN ); child.setTextFormatForState( MyFormats.SELECTED, SkinStates.SELECTED ); child.setTextFormatForState( MyFormats.DISABLED, SkinStates.DISABLED ); child.setTextFormatForState( MyFormats.DISABLED_SELECTED, SkinStates.DISABLED_SELECTED ); } } }

 With that class in place you then use   new MySegmentedCtrl()  instead of   new SegmentedControl()  and otherwise procede as normal.


My app : Get set - Get up!   Get ready for the snooze revolution.