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

Adobe AIR Development

Reply
Contributor
Posts: 19
Registered: ‎08-26-2008
My Device: Not Specified
Accepted Solution

picker issues

Hi,

 

I'm having trouble getting the picker to work. What I need is a simple picker that can get a date for me. I used he example from SDH api reference. It displays fine. However as soon as you change that date it will just jump back to the original date. It is like the entire picker is restarted as soon s something gets changed.I did not change anythign to the code. I only put it in my own class and then create it from the main program. Code is below. Anyone had the same issue or knows a solution?

 

package classes
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	import qnx.ui.data.DataProvider;
	import qnx.ui.picker.Picker;
	import qnx.ui.text.Label;
	
	[SWF(height="600", width="1024", frameRate="30", backgroundColor="#BBBBBB")]
	public class ClsDatePicker extends Sprite
	{
		public function ClsDatePicker()
		{
			// Create three arrays to handle days, months, years.
			
			var arrDay:Array=[];
			var arrMonth:Array=[];
			var arrYear:Array=[];
			
			// Populate the month array and create the
			// day DataProvider 
			
			for (var i:int=1; i<32; i++) {
				arrDay.push({label: i.toString()});
			}
			
			var dayDP:DataProvider=new DataProvider(arrDay);
			
			
			// Populate and month array and create the month
			// DataProvider
			
			arrMonth.push({label: "January"});
			arrMonth.push({label: "February"});
			arrMonth.push({label: "March"});
			arrMonth.push({label: "April"});
			arrMonth.push({label: "May"});
			arrMonth.push({label: "June"});
			arrMonth.push({label: "July"});
			arrMonth.push({label: "August"});
			arrMonth.push({label: "September"});
			arrMonth.push({label: "October"});
			arrMonth.push({label: "November"});
			arrMonth.push({label: "December"});
			
			var monthDP:DataProvider=new DataProvider(arrMonth);
			
			// Create the year DataProvider
			
			for (var l:int=1900; l<2050; l++) {
				arrYear.push({label: l.toString()});
			}
			
			var yearDP:DataProvider=new DataProvider(arrYear);
			
			// Add the day, month and year DataProviders to the main
			// array
			
			var dpp:Array = new Array();
			
			dpp.push(dayDP);
			dpp.push(monthDP);
			dpp.push(yearDP);
			
			// Create the picker and add the main DataProvider
			
			var picker:Picker = new Picker();
			
			picker.width=400;
			picker.height=30;
			picker.x=picker.y=300;
			picker.dataProvider=new DataProvider(dpp);
			addChild(picker);
			
			
			// To customize column widths,
			// all widths are added up and then used for  
			// a ratio against the component set width
			
			picker.setListWidth(0,100);
			picker.setListWidth(1,300);
			picker.setListWidth(2,200);
			
			// Set to Jan 1, 2010
			
			picker.selectedIndices=[0,0,110];
			
			// Add listeners for open, close and select events
			
			picker.addEventListener(Event.OPEN,handleOpen);
			picker.addEventListener(Event.CLOSE,handleClose);
			picker.addEventListener(Event.SELECT,handleSelect);
			picker.addEventListener(Event.CHANGE,handleChange);
			
			// A simple function that displays currently selected
			// item information in the console. 
			
			traceItems();
			
			function traceItems():void
			{
				for (var j:int = 0; j <picker.selectedItems.length; j++) {
					trace("Picker.selectedItems " +picker.selectedItems[j].label);
				}
				trace("Picker.selectedIndices "+picker.selectedIndices);
				trace("Picker.data "+picker.data);
			}
			function handleSelect(e:Event):void {
				trace("Picker.select event captured");
				
				traceItems();
			}
			
			function handleOpen(e:Event):void {
				trace("Picker.open event captured");
			}
			function handleClose(e:Event):void {
				trace("Picker.close event captured");
			}
			function handleChange(e:Event):void {
				trace("Picker.change event captured");
			}


		}
	}
}

 

Highlighted
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: picker issues

It appears to be some sort of bug involving the height of either the picker or the rows.  I haven't explored enough to find the precise problem, but if you set "picker.height = 50" you should at least not see the current problem.

 

Note also the object has rowHeight, and maybe you can find some combination of the two which works for you.

 

If you figure it out perfectly, please submit a bug report in the issue tracker, if it does in fact appear to be a bug.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: picker issues

hey,

 

from the looks of your code nothing is a problem. but after running a few tests the problems seems to only happen if you set the height of the picker to anything less than 31. i have no idea why that is the case. it might be a bug. seems to have a minimum height issue. here's where you need to change the code:

 

 

var picker:Picker = new Picker();

picker.width=400;
picker.height=31;
picker.x=picker.y=300;
picker.dataProvider=new DataProvider(dpp);
addChild(picker);

 

so again anything higher than 30 will work. hope that helps. good luck!

 

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman