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

Native Development

Reply
Highlighted
Developer
Posts: 237
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha
My Carrier: Telkomsel

ListView LoadMore using ListScrollStateHandler doubled at first

Hi, I'm using ListView

And I'm using ListScrollStateHandler , onAtEndChanged to load more item

 

But at first request always doubled (should only get 10 item, but get 20 item)

How to fix this?

 

my code is something like this :

 

Button {
   onClicked : { // when this button click, listView will get data twice instead one
      myPage = 1;
      requestItem(myPage);
   }
}

ListView {
//...
attachedObjects: [
   ListScrollStateHandler {
      onAtEndChanged: {
        if (atEnd && isLoadmore) {
           myPage = myPage + 1;
           requestItem(myPage); // this will get dataModel for ListView
        }
      }
   }
]
/...
}

 

 

Thanks

Developer
Posts: 237
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha
My Carrier: Telkomsel

Re: ListView LoadMore using ListScrollStateHandler doubled at first

Hi any suggestion?

 

 

Thanks

Retired
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: ListView LoadMore using ListScrollStateHandler doubled at first

Hi,

 

I think we'd need to see more complete code to be helpful...

 

For example, where's myPage defined? Which scope? The Button and the ListView's ListScrollStateHandler are both accessing it as though local / instance...

 

Thanks.

--
Rob is no longer associated with BlackBerry.
Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: ListView LoadMore using ListScrollStateHandler doubled at first

When the ListView is initialized, you have the chance of atEndChanged being called since there are no items in it and effectively you are at the end of the list. Then when it populates and you scroll to the end you get it again.
Like all of my posts