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
New Developer
Posts: 47
Registered: ‎11-25-2010
My Device: Not Specified
Accepted Solution

DatePicker in Tablet

Hi,

 

I want a date picker control so that date of birth can be chosen from that, i can not use mx.controls.DateField as this will not support our emulator. Please suggest how to do

Highlighted
Developer
Posts: 192
Registered: ‎09-23-2009
My Device: 9860/PlayBook/Dev Alpha
My Carrier: Plus GSM

Re: DatePicker in Tablet

I didn't found one, it looks like you will have to create your own controll basing on PickerList or Picker. Maybe it will be added later (or not, who knows).

Found my post helpfull? Like it! It solves your trouble? Help others and accept it as solution. Search before asking.
My apps: Secret Cod3s | Should my tablet be banned?
--
Jakub Nietrzeba
PGS Software S.A.
Your reliable partner in Poland - IT Outsourcing - BlackBerry, iPhone, Web and Standalone applications
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: DatePicker in Tablet

hey ramesh,

 

if you need a code sample you can refer to and a quick way to populate your data picker fields here is a sample from the ASDocs:

 

 

 // A short example of a picker component that displays
 // day, month and year. 
package
{
    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 PickerSample extends Sprite
    {
        
        public function PickerSample()
        {
            
            // 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<2011; 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=50;
            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);
            
            // 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 {
                traceItems();
            }
            
            function handleOpen(e:Event):void {
                trace("Picker.open event captured");
            }
            function handleClose(e:Event):void {
                trace("Picker.close event captured");
            }
        }
    }

}

 

i've tested it and it runs fine. 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
New Contributor
Posts: 8
Registered: ‎11-17-2010
My Device: BlackBerry PlayBook
My Carrier: Verizon

Re: DatePicker in Tablet

I am interested in a DatePicker or Calendar control. What is more "native" like to the PlayBook? Is there a pop-up Modal dialog? Can I use the mxSmiley Very HappyateChooser and skin it to be more touch friendly? Or will there be a specific component provided by BlackBerry?

 

This is very much essential from my application I'm building.

 

Thanks

Bobby Rafferty

@bobbyworld

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

Re: DatePicker in Tablet

You can use the Picker class to select a data.

 

http://www.blackberry.com/developers/docs/airapi/1.0.0/index.html

 

You will need to confirm that the selected date is valid or dynamically change the date column based on the currently selected month and year (leap year).

 

sorry, no out of the box date selection, but just a few lines of code will get you where you need to be.

New Developer
Posts: 47
Registered: ‎11-25-2010
My Device: Not Specified

Re: DatePicker in Tablet

Thanks for the reply, it is working. Smiley Happy

New Contributor
Posts: 8
Registered: ‎11-17-2010
My Device: BlackBerry PlayBook
My Carrier: Verizon

Re: DatePicker in Tablet

Excellent work! Have you looked into the flash.globalization.DateTimeFormatter class or DateTimeStyle?

 

I believe it's a new class in Flash Player 10.1

 

Bobby

@bobbyworld

Developer
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook
My Carrier: N/A

Re: DatePicker in Tablet

just a note:  that example from the documentation doesn't include logic for leap years or for months that have less than 31 days (February, April, June, September and November).


PlayBook Applications:
Drop Swatch
Contributor
Posts: 22
Registered: ‎12-17-2010
My Device: Not Specified

Re: DatePicker in Tablet

Actually a calendar control contains alot of logic when you have a look at e.g. Java or .NET implementations. Leap years are just the beginning ... hopefully there will be a standardized date picker control like in every UI framework out there. Otherwise we will soon have dozens of different "date picking" aproaches ;-)

New Developer
Posts: 7
Registered: ‎11-04-2010
My Device: Not Specified

Re: DatePicker in Tablet

I've tried compiling the picker sample sample and I get a compile error on this line:

 

            picker.selectedIndices=[0,0,110];

 

Compile Error:

           Access of possibly undefined property selectedIndices through a reference with static type qnx.ui.picker: Picker.

 

 

Is it possible I have an old version of the Blackberry SDK? Anyone else seeing this issue?

Strange since the control works fine if I comment out this line, but pretty useless as I cannot set the current date.

 

Thanks for any replies.

Mike