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
Developer
SumiSadiq
Posts: 141
Registered: ‎04-08-2013
My Device: Blackberry 10
My Carrier: Blackberry

Load different ListView on button click

Hi,

 1)Iam having a table named ' location ' in DB and it contains name of states inside and outside India.

 2)Iam having a page containing 3 buttons and a listView

 3)When I press the first button I want to display all the states.

 4)When I press the second button I want to display states in India.

5)When I press the third button I want to display states outside India.

6)All these states have to be displayed in a listView

 

My Question is:

I tried this using 3 listView and enabling and disabling them while selecting the buttons.Is this approach is right??

Please help me with some best solution

Please use plain text.
Developer
simon_hain
Posts: 15,870
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Load different ListView on button click

a single listview should be ok, just change the datamodel to reflect the changes.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
SumiSadiq
Posts: 141
Registered: ‎04-08-2013
My Device: Blackberry 10
My Carrier: Blackberry

Re: Load different ListView on button click

Thanks simon fior your reply,

  If any of the button is clicked I will clear the dataModel and then load them with needed data from db.Will this cause delay in loading the listView

Please use plain text.
Developer
YamilBracho
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Load different ListView on button click

It depends on how much data your will load. If it's large, it's good idea to show an ActivityIndicator to the users...

Please use plain text.
Developer
canadainc
Posts: 19
Registered: ‎07-02-2013
My Device: BlackBerry Q10
My Carrier: Telus

Re: Load different ListView on button click

If you do notice a lag and you don't mind taking up a bit more memory, you can always just have three different data models pointing to your three databases. Then when the user selects between the buttons, simply reattach your ListView's data model to point to the appropriate one. This should cause minimal performance hit because the data is already loaded.

The only drawback here is that you will have to keep the data in memory (and load it initially) which might be an initial hit.
Please use plain text.
Developer
SumiSadiq
Posts: 141
Registered: ‎04-08-2013
My Device: Blackberry 10
My Carrier: Blackberry

Re: Load different ListView on button click

Thanks for your reply.I need to load only 20 states name at a time.Did u mean to use only one listView and reattach 3 different dataModels for the same ListView.Plz clarify that.Plz help me with some code
Please use plain text.