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
Highlighted
Developer
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000
My Carrier: Vodafone
Accepted Solution

LastVisibleItem

Can someone provide me with an example of how I can find the name of the last item that is visible in a list. I tried the following, but that gives me a null value, while the list has a number of entries.

 

trace("Last visible item: " + myList.lastVisibleItem);

 

Eugene

My PlayBook App: Checklists
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: LastVisibleItem

hey,

 

i did a few tests a little while back. from what i remember the lastVisibleItem only works after u scroll the list. try scrolling and then checking.

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
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: LastVisibleItem

hey,

 

just a follow up. just re-ran my code and saw that there is a race condition type thing going on. bascially when you do the lastVisibleItem property right after you make the list, the list hasnt been fully created yet so it doesnt have a value lastVisibleItem property. i put in a delayed trace and it seemed to work. here is the sample code i ran:

 

ListTests.as:

 

 

package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.utils.setTimeout;

import qnx.ui.data.DataProvider;
import qnx.ui.events.ListEvent;
import qnx.ui.listClasses.DropDown;
import qnx.ui.listClasses.List;
import qnx.ui.listClasses.ListSelectionMode;
import qnx.ui.listClasses.RoundList;
import qnx.ui.picker.PickerList;


[SWF(width="1024",height="600",backgroundColor="#e8e8e8",frameRate="30")]
public class ListTests extends Sprite
{
private var myList:List;
private var myDataProvider:DataProvider;
private var myArray:Array;

public function ListTests()
{
super();

// support autoOrients
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;

myList = new List();
myArray = new Array();

myArray.push({label: "Thomas Luddington", selected: false});
myArray.push({label: "Master Maruyn", selected: false});
myArray.push({label: "Master Gardyner", selected: false});
myArray.push({label: "Captain Vaughan", selected: false});
myArray.push({label: "Master Kendall", selected: false});
myArray.push({label: "Master Prideox", selected: false});
myArray.push({label: "Robert Holecroft", selected: false});
myArray.push({label: "Rise Courtenay", selected: false});
myArray.push({label: "Master Hugh Rogers", selected: false});
myArray.push({label: "Thomas Foxe", selected: false});
myArray.push({label: "Edward Nugen", selected: false});
myArray.push({label: "Darby Glande", selected: false});
myArray.push({label: "Edward Kelle", selected: false});
myArray.push({label: "Iohn Gostigo", selected: false});
myArray.push({label: "Erasmus Clefs", selected: false});
myArray.push({label: "Edward Ketcheman", selected: false});
myArray.push({label: "Iohn Linsey", selected: false});
myArray.push({label: "Thomas Rottenbury", selected: false});
myArray.push({label: "Roger Deane", selected: false});
myArray.push({label: "Iohn Harris", selected: false});

myDataProvider = new DataProvider(myArray);

myList.dataProvider = myDataProvider;

/**
* set the cell renderer to the renderer holding
* your new skin
*/

myList.selectionMode = ListSelectionMode.NONE;
myList.rowHeight = 55;
myList.setPosition(100,25);
myList.setSize(500, 400);
myList.setSkin(MyRenderer);


addChild(myList);

setTimeout(function():void{trace("Last Visible Item: " + myList.lastVisibleItem.index);}, 1000);



}
}
}

 

hope that sheds some light. 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
Developer
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000
My Carrier: Vodafone

Re: LastVisibleItem

I would have never figured this out. Thanks a lot (again ;-)!

Eugene

My PlayBook App: Checklists