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
Developer
gpatton
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900
Accepted Solution

Drop Down List

Hi guys,

 

I've just started making an app for the PlayBook so pardon my "n00b-ishness".

I have a simple question about drop down menus. My code is below. When I view this on the simulator I get a drop down with just the word "Background" and when I click on the arrow, I get one blank line. Nothing inside it. I've searched the forums and can't find anything specific to this one. Please let m e know.

 

 

var backgroundOptions:DropDown = new DropDown();
			backgroundOptions.rowCount = 8;
			backgroundOptions.rowHeight = 30;
			backgroundOptions.prompt = "Background";
			backgroundOptions.x = 20;
			backgroundOptions.y = 300;
			var dp:DataProvider = new DataProvider();
			var listOfBackgrounds:Array = new Array([{label: 'Black'},
				{label: 'Green'},
				{label: 'Blue'},
				{label: 'White'},
				{label: 'Slow Lines'},
				{label: 'Abstract'},
				{label: 'Lines'},
				{label: 'Aurora'}]);
			
			dp.setItems(listOfBackgrounds);
			backgroundOptions.dataProvider = dp;
			addChild(backgroundOptions);

 

Any help would be great!

 

Thanks!

 

 

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

Re: Drop Down List

Try:

 

 

var backgroundOptions:DropDown = new DropDown();
backgroundOptions.rowCount = 8;
backgroundOptions.rowHeight = 30;
backgroundOptions.prompt = "Background";
backgroundOptions.x = 20;
backgroundOptions.y = 300;

var listOfBackgrounds:Array = new Array([{label: 'Black'},
{label: 'Green'},
{label: 'Blue'},
{label: 'White'},
{label: 'Slow Lines'},
{label: 'Abstract'},
{label: 'Lines'},
{label: 'Aurora'}]);

backgroundOptions.dataProvider = new DataProvider( listOfBackgrounds );
addChild( backgroundOptions );

 

 

Developer
gpatton
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900

Re: Drop Down List

Hey jtegen,

 

I tried the solution you posted, but unfortunately I still get the same blank line as the first.

Sorry.

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

Re: Drop Down List

[ Edited ]

I see it now.  You're creating an array of arrays.  Try:

 

 

var listOfBackgrounds:Array = new Array({label: 'Black'},
				{label: 'Green'},
				{label: 'Blue'},
				{label: 'White'},
				{label: 'Slow Lines'},
				{label: 'Abstract'},
				{label: 'Lines'},
				{label: 'Aurora'});

 

No square brackets in the Array constructor.  Just an array of objects.

 

Developer
gpatton
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900

Re: Drop Down List

Perfect kind sir!

It worked!

 

Thanks so much! I've been racking my brain since 8am this morning and its 1.30pm now.

Time for a break maybe? :smileyhappy:

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

Re: Drop Down List

Just think, you'll never make that mistake in your lifetime again (or for at least a week).

Good luck.

Contributor
gaurav2k11
Posts: 20
Registered: ‎03-04-2011
My Device: 9800

Re: Drop Down List

 

hello ..

 

 

i m stuck in a probm please help me 

i m making a drop down menu ...in which there are some text now i want to if that particular text selected than it should perform the task.

the code through which i m adding the dropdown menu is...

 

 

 

              String choices[] = {"Please Select The Time Period",
                                                "Current Month",
                                                "Last Month",
                                               "Current Quater",
                                               "1st Quarter",
                                              "2nd Quater",
                                                 "3rd Quater",
                                                 "4rth Quater",
                                                   "Half Yearly",
                                                 "Last Financial Year",
                                                 "Slected Period"};
        int iSetTo = 0;
        int iIncrement = 1;

           add(new ObjectChoiceField("",choices,iSetTo,iIncrement));
now if i select any of that string than it should go to net page or can perform any dialoug....
please do that i need that ver urgentlly....
thanx ...

 

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

Re: Drop Down List

@gaura2k11:  This is the Adobe AIR/AS3 forum.  The code you posted does not appear to be AS3.  If you are in the correct forum, please post the actual code snippet you are having trouble with.

Contributor
gaurav2k11
Posts: 20
Registered: ‎03-04-2011
My Device: 9800

Re: Drop Down List

[ Edited ]

 

package com.Tally.app;
import java.util.Vector;
import javax.microedition.lcdui.Choice;
import com.Tally.screenParams.CompanyList;
import com.Tally.screenParams.CrDrList;
import com.Tally.screenParams.ProfitLossList;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.ChoiceField;
import net.rim.device.api.ui.component.DateField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.component.ObjectChoiceField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.picker.DateTimePicker;
public class ProfitLoss extends MainScreen
{
 public ProfitLoss() {
 add(new NEWProfitLoss());
 
  
}
         class NEWProfitLoss extends VerticalFieldManager implements FieldChangeListener{
     public NEWProfitLoss(){
     super(VerticalFieldManager.USE_ALL_HEIGHT);
     LabelField SubmitButton;
   LabelField f = new LabelField("Ledger Details ");
   f.setPadding(0,0,0,110);
   add(f);
   add(new SeparatorField());
   add(new LabelField());
  
 
   HorizontalFieldManager GrandManager = new HorizontalFieldManager();
   LabelField GrandButton  = new LabelField(ProfitLossList.plGrandTotal, LabelField.FOCUSABLE){
  
                 protected boolean navigationClick(int status, int time) {
   fieldChanged(this, 0);
   return true;
   };
    
   };
   
      
   GrandButton.setText("  Net Profit:  ");
 GrandManager.add(GrandButton);
 LabelField lf = new LabelField(ProfitLossList.plGrandTotal);
 lf.setPadding(0,0,0,100);
 GrandManager.add(lf);
 add(GrandManager);
        
          add(new LabelField());
          
          String choices[] = {"Please Select The Time Period",
           "Current Month",
           "Last Month",
           "Current Quater",
           "1st Quarter",
           "2nd Quater",
           "3rd Quater",
           "4rth Quater",
           "Half Yearly",
           "Last Financial Year",
           "Slected Period"};
        
        int iSetTo = 0;
        int iIncrement = 1;
        
        ObjectChoiceField choice = new ObjectChoiceField("",choices,iSetTo,iIncrement);
        add(choice);
 
   
       add(new LabelField());
       
       SubmitButton  = new LabelField("Submit", LabelField.FOCUSABLE){
    protected boolean navigationClick(int status, int time) {
              
fieldChanged(this, 0);
 
 
return true;
 
};
 
};
   SubmitButton.setText("Submit");
 
 SubmitButton.setPadding(0,0,0,180);
 add(SubmitButton);
     
 private void addActionListener(NEWProfitLoss newProfitLoss) {
 // TODO Auto-generated method stub
 }
 protected void paintBackground(Graphics g) {
 // TODO Auto-generated method stub
 g.setColor(0x33FF66);
 g.fillRect(0, 0, net.rim.device.api.system.Display.getWidth(), net.rim.device.api.system.Display.getHeight());
 g.setColor(Color.BLUE);
 super.paintBackground(g);
 }
 protected void paint(Graphics graphics) {
 graphics.setColor(Color.WHITE);
 graphics.fillRect(0,0,Display.getWidth(),20);
 graphics.setColor(Color.BLACK);
super.paint(graphics);
}
protected void sublayout(int maxWidth, int maxHeight) {
// TODO Auto-generated method stub
setExtent(net.rim.device.api.system.Display.getWidth(), net.rim.device.api.system.Display.getHeight());
super.sublayout(net.rim.device.api.system.Display.getWidth(), net.rim.device.api.system.Display.getHeight());
}
     
  
   

 

 

here is the full code of that page ...that drop down menu item is adding on the screen now i need to call the function of that each menu please help me on that....

thankyou

 

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

Re: Drop Down List

@gaurav2k11:  This is an Action Script forum (Adobe AIR), not a Java forum.  You may want to post the code there for help.