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
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN
Accepted Solution

How to interact display object inside a custom list ?

Hi All,

 

I am implemented a custom list using cellrender class 

 

=================================

Label1                                               = ======

                                                            =Image=

Lable2                                               =======

=================================

=================================

Label1                                               = ======

                                                            =Image=

Lable2                                               =======

=================================

 

Abouve shown is my list structure i need to listen click in that image . How to do that .. 

 

Please help

 

Thanks

Deepu George

 

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

Re: How to interact display object inside a custom list ?

There is a couple of ways to do it. Simple way is to add the callback function in the data provider and if it is there, set the image click event to that callback function. Another way is to have a static function (not typically great); a third is to have a singleton that can have the callback.
Developer
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Re: How to interact display object inside a custom list ?

Hi jtegen,

Can u please give a sample code snippet to include callback function inside dataprovider
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: How to interact display object inside a custom list ?

It would be something like this:

 

mylist.addItem( { data : obj.uniqueid, label : obj.label, callback : this.myFunction } );

 

// in provider

if( data.hasOwnProperty( 'callback' ) )

{

  this.image.addEventListener( MouseEvent.CLICK, data.callback );

}

 

If you have to know which image was clicked on, then your event listener would be in the renderer, that would create a unique event with the renderer data object that would then be called to the renderer callback function.

 

 

Developer
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Re: How to interact display object inside a custom list ?

Got an Error 'Access of undefined property image'
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: How to interact display object inside a custom list ?

'image' would be your image property in your renderer.
Developer
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Re: How to interact display object inside a custom list ?

Hi jtegen,

 

Please look at the code shown below

 

Renderer

 

package com.skin.deepu
{
import flash.events.MouseEvent;

import qnx.fuse.ui.display.Image;
import qnx.fuse.ui.listClasses.CellRenderer;
import qnx.fuse.ui.text.Label;


public class SettingsListRender extends CellRenderer
{
private var sublabel:Label;// = new Label();
private var deleteIcon:Image;
public function SettingsListRender()
{
super();
sublabel = new Label();
deleteIcon = new Image();
}

override public function set data(value:smileysurprised:bject):void
{
// TODO Auto Generated method stub
super.data = value.data;

upadateUI();
}
private function upadateUI():void
{

label.text = data.heading;

sublabel.width = 500;
sublabel.y = 100;
sublabel.x = 30;
sublabel.id = data.id;

sublabel.text = data.subHeading;

addChild(sublabel);

deleteIcon.setImage("com/cellapp/data/monitor/images/actionIcon/ic_delete.png");
deleteIcon.x= 680;
deleteIcon.y = 30;
deleteIcon.alpha = data.imageAlpha;

addChild(deleteIcon);



}





}
}

LIst Declaration

 

for (var i:int = 0; i < networkArray.length; i++)
{
var object:smileysurprised:bject = new Object();
object.heading = networkArray[i];
object.subHeading = "not setted";
object.id = "deactivated";
object.imageAlpha = 0;
listDataProvider.addItem({data&colon;object,callback:this.imageCallBack});
}

//set the dataProvider
list.dataProvider = listDataProvider;

 

the above code i am implemented. As per our pervious discussion i am extended data provider class and inside AddItem overridden function i am check it out 

if( data.hasOwnProperty( 'callback' ) )

{

    trace("true");

}

it retrives the value true. But my problem is how can i get image property inside the data provider ..

 

Thanks

With Regards

Deepu George 

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

Re: How to interact display object inside a custom list ?

In your renderer, at the override data function, set the listener there:

deleteIcon.addEventListener( 'click', value.callback );

No certain why in that function you are only setting the data portion of your data object. I guess you are not wanting to carry the callback portion.
Developer
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Re: How to interact display object inside a custom list ?

Again crashing with error 

 

Parameter listener must be non-null.

Developer
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Re: How to interact display object inside a custom list ?

Got it ,added callback function in main object . But the same time "ListEvent.ITEM_CLICKED" is also trigering . How to stop it ..