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
gluth
Posts: 192
Registered: ‎09-23-2009
My Device: 9860/PlayBook/Dev Alpha
My Carrier: Plus GSM

Re: CellRander

Search for example in this forum, this question was asked many times, and do not post with the same question every five minutes, we can hear you.

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
Please use plain text.
Contributor
razzlakki
Posts: 11
Registered: ‎11-20-2010
My Device: Not Specified

Re: Customized List

I want to insert diffrent diffrent images acording to the name...in a list

 

598.png 

 

Like this ... i need design the List this way like one cell contain diffrent fields .... how can I creat this kind of List?


please reply me as soon as posible.......

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Customized List

Here is a solution:

 

iconlist.jpg

Ignore the look of the font, since the screen shot was taken from AIR and not the simulator.

 

Application Code:

package
{
  import flash.display.Sprite;
	
  import qnx.ui.data.DataProvider;
  import qnx.ui.listClasses.List;
  import qnx.ui.listClasses.ListSelectionMode;
	
  import renderer.IconListRenderer;

  [SWF(height="600", width="1024", frameRate="30", backgroundColor="#000000")]
  public class LayoutExample3 extends Sprite
  {
	// attributes
	private var list :List = new List();
		
	// assets
	[Embed(source='assets/icon1.png')] private var icon1  : Class;
	[Embed(source='assets/icon2.png')] private var icon2  : Class;
	[Embed(source='assets/icon3.png')] private var icon3  : Class;
		
	// font
	//[Embed(source='../assets/fonts/DejaVuSans.ttf', fontName='bbFont', mimeType='application/x-font' )] private var sysfont : Class;

	///////////////////////////////////////////////////////////////
	public function LayoutExample3()
	{
		super();
		stage.nativeWindow.visible = true;

		this.list.x = 200;
		this.list.y = 10;
		this.list.height = 400;
		this.list.width  = 300;
		this.list.rowHeight = 45;
		this.list.selectionMode = ListSelectionMode.SINGLE;
		this.list.allowDeselect = false;
		this.list.setSkin( renderer.IconListRenderer );
		this.addChild( this.list );
		this.list.dataProvider = new DataProvider( [
                        {icon: new icon1(), label:'Labs Tests & Procedures'},
		      {icon: new icon2(), label:'Allergies'},
		      {icon: new icon3(), label:'Immunizations'}] );
		this.list.selectedIndex = 0;
			

	}
		

  }
}

 

In the directory renderer:

 

package renderer
{
  import flash.display.DisplayObject;
  import flash.display.Sprite;
  import flash.text.TextFormat;
	
  import qnx.ui.display.Image;
  import qnx.ui.listClasses.CellRenderer;
	
  public class IconListRenderer extends CellRenderer
  {
	private var image :Image;

	///////////////////////////////////////////////////////////////
	public function IconListRenderer()
	{
	  super();
	  this.image = new Image();
	  this.label.visible = true;
           this.addChild( this.image );
	}
		
		
	///////////////////////////////////////////////////////////////
	override protected function draw():void
	{
		super.draw();
		trace( 'draw' );
		this.graphics.clear();
		this.graphics.lineStyle( 1, 0x999999, 1.0 );
		//this.graphics.beginFill( 0xFFFF00 );
		this.graphics.drawRect( 0, 0, this.width, this.height );
		this.graphics.endFill();
	}
	
	////////////////////////////////////////////////////////////////
	override protected function drawLabel():void
	{
		super.drawLabel();
			
		if( this.data )
		{
		  this.image.setImage( this.data.icon );
		  this.image.x = 5;
		  this.image.y = 10;
		}
			
		// shift the label over
		if( this.label )
		{
			this.label.x = 40;
		}
	}

  }
}

 

This did not work as I would have expected.  The data attribute does not come alive until the drawLabel method.  I would have assumed that it would be available in the constructor or at least in the onAdded method.  The draw() method did not allow me to do a proper gradient fill without causing all sorts of other problems.  Leaving it out gives you no borders, so this is a step forward. I was surprised the draw methods were called before the constructor (using trace(...)).  Very odd.

 

Follow on work:

If anyone could figure out how to get the gradient to work on the draw() method, would be a nice touch.  The beginFill(...) call seems to be ignored and without calling the super.draw() method, the offset of 0,0, seems to shift (but the fill does occur).  Seems like a bug.

Please use plain text.
Contributor
razzlakki
Posts: 11
Registered: ‎11-20-2010
My Device: Not Specified

Re: Customized List

thank u for responce. I got solution but some times i got one error like thiserror.jpg

how can i rectify this problem

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Customized List

Runtime error or compile error? When does this occur?

Does not look like a runtime error.

Please use plain text.
Contributor
razzlakki
Posts: 11
Registered: ‎11-20-2010
My Device: Not Specified

RuntimeError

[ Edited ]

Run time error

[Embed(source='1.png')] private var icon1  : Class;
        [Embed(source='2.png')]private var icon2  : Class;
        [Embed(source='3.png')]private var icon3  : Class;
        [Embed(source='4.png')]private var icon4  : Class;
        [Embed(source='5.png')]private var icon5  : Class;
        [Embed(source='6.png')]private var icon6  : Class;
        [Embed(source='7.png')]private var icon7  : Class;
        [Embed(source='8.png')]private var icon8  : Class;
        [Embed(source='9.png')]private var icon9  : Class;
        [Embed(source='10.png')]private var icon10   : Class;
        [Embed(source='11.png')]private var icon11  : Class;

 

in dp..this.list.dataProvider = new DataProvider( [
                {icon: new icon1(), label:'Emergency Contacts'},
                {icon: new icon2(), label:'General Information'},
                {icon: new icon3(), label:'Medicaitons'},
                {icon: new icon4(), label:'Past Medications'},
                {icon: new icon5(), label:'Prescriptions'},
                {icon: new icon6(), label:'Dietary_supplements'},
                {icon: new icon7(), label:'Lab Tests & Procedures'},
                {icon: new icon8(), label:'Allergies'},
                {icon: new icon9(), label:'Immunizations'},
                {icon: new icon10(), label:'Surgical-Procedures'},
                {icon: new icon11(), label:'Diagnoses'},]);

first time it runs with out any error 2nd time on words error occured.

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: RuntimeError

It does not appear to be a ActionScript runtime error, but a Java launch error.  Can anyone else help with this?

Please use plain text.