LastVisibleItem

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

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

Hey,.

just a follow-up. Simply re-directed my code and saw that there is a race condition that kind of thing going. Bascially when you do the lastVisibleItem property right after making the list, the list has not been fully created yet so it doesn't have a lastVisibleItem property value. I put in a trace of delayed and it seemed to work. Here is the sample code that I fell:

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!

Tags: BlackBerry Developers

Similar Questions

  • Custom CellRenderer class

    I have a qnx.ui.listClasses.List with a custom made cell that contains a check box as in the example "Creating a custom list" here:

    http://docs.BlackBerry.com/en/developers/deliverables/23959/Creating_a_custom_list_1446778_11.jsp

    After setting the skin with:

    myList.setSkin(MyCustomCellRenderer);
    

    Is there anyway to access the checkbox to select or deselect without actually clicking on the check itself? When a control is clicked, it sends an event through specific cell renderer.

    The closest I found is List.firstVisibleItem and List.lastVisibleItem but these are not constant during execution.

    What I want to do is to loop over a list that contains boxes check after loading the xml data and select or deselect the item in the list.

    Any help would be greatly appreciated.

    Too bad. I thought about it. You can override the data function defined as follows.

    override public function set data(data:Object):void{    super.data = data;    check.selected = MyObject( data ).Selected;}
    

Maybe you are looking for