BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-17-2008, 02:47 PM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2008
Model: 7100T
PIN: N/A
Carrier: Programmer
Posts: 50
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default ListField problem

Please Login to Remove!

Hello...
i've been trying to undserstand how the ListField works...
i'm stating from the loading side, instead of the saving side...which i now sound kinda crazy, but that's the way it has to be...
So i'm trying to load the ListFrield like...
Code:
ListField n = new ListField();
now how do i make n be the lsit field i wanted?
like...to search this place to see how many item are there now etc etc
so that after this code when i typed:
Code:
n.getSize();
it would appear exacly the number of "names" i saved....
Offline  
Old 07-17-2008, 03:21 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

I'm having a hard time finding a specific question here. Can you tell us what you are trying to accomplish?

My suggestion is to look at ObjectChoiceField first, this is somewhat more straight-forward to implement and will probably handle your task.
Offline  
Old 07-17-2008, 03:36 PM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2008
Model: 7100T
PIN: N/A
Carrier: Programmer
Posts: 50
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

well
i'm trying to load a list of names...
but what do i have to load? like...an ID? a name?
and how do a actually load it using the ListField?
Offline  
Old 07-17-2008, 03:55 PM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2008
Model: 7100T
PIN: N/A
Carrier: Programmer
Posts: 50
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

anyway...what i wanna do is to have like a second phonebook
but this one, the person on the phone doesn't have control...
who has control are ohter people and they'll controll it from a computer, or another phone
in other post someone gave me the idea to send the data for that in an email...and that should do...
it would be...someone sends an email to a phone, and this person's phone is going to recognize the email even before it show on the screen, because this program is going to have a filter for the emails that start with a certain code(which an normal email is never going to start like)...
this email is going to be something like:
!@#$%!$#@!$@#$@!#-NAME-1234567
So basically the phone would recognize the !@#$%!$#@!$@#$@!#-...so it would save whatever comes after the - and before the next -...as the Name of hte person and then it would save whatever comes after the - as the number...

so basically this app would open and load all the names that it saved ever
so i think it would save in some kind of ID
so the ListField would have to load this ID
this is my question, how do i load it?
Offline  
Old 07-17-2008, 05:40 PM   #5 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

What happens to the items in the list, once the list is loaded? Does the user select an item from the list?

As a general answer to your question, you would retrieve the list of items from your datastore (as an array of some Object), then pass this list to the ListField.

For example: create an instance of ObjectListField(), then use insert() to add the individual list elements from your data.

You must create a Screen (I suggest subclassing MainScreen), then add your ObjectListField to the Screen using the method add().

All of this is documented in the API reference, and there are numerous examples on the Developers web site.
Offline  
Old 07-17-2008, 05:47 PM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2008
Model: 7100T
PIN: N/A
Carrier: Programmer
Posts: 50
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok...you're explanation was pretty much what i needed i think
but i'll only be able to test it tomorrow, because my debugger is not working for some weird reson and i'm about to go home


but answering your question...once the list is loaded, i wanted to list on the screen all the names that it found...if there are no names it would appear as *empty* like the default of the bb
Offline  
Old 07-18-2008, 10:03 AM   #7 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2008
Model: 7100T
PIN: N/A
Carrier: Programmer
Posts: 50
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Dougsg38p View Post
What happens to the items in the list, once the list is loaded? Does the user select an item from the list?

As a general answer to your question, you would retrieve the list of items from your datastore (as an array of some Object), then pass this list to the ListField.

For example: create an instance of ObjectListField(), then use insert() to add the individual list elements from your data.

You must create a Screen (I suggest subclassing MainScreen), then add your ObjectListField to the Screen using the method add().

All of this is documented in the API reference, and there are numerous examples on the Developers web site.
ok...
the part of adding the ObjectListField to the Screen i understand
but again...how am i going to load the ListField onthe ObjectListField?
let's say, this second phone book is saved on the id: 0xf06c2b5d95e704c8L.

can you be more specific on how am i going to load it, like using actual codes?
Offline  
Old 07-18-2008, 11:22 AM   #8 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

How are you storing the list in the datastore? Whatever it is, you'll use some container to hold the actual data: example a Vector, HashTable, etc.

I typically use a hashtable. The table is stored in a PersistentStore. You really need to read up on the use of PersistentStore. This allows you to store an Object in the device storage.

Once you have this working, you will simply retrieve the container object from the store, retreive the contents of the container (using whatever is the appropriate method for that container), and then insert() the list items into the ObjectListField.

If you look at your sample programs that came with the JDE, you will find several examples of this. There are also several articles in the Blackberry Developer Knowledgebase on the subject.
Offline  
Old 07-18-2008, 11:30 AM   #9 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2008
Model: 7100T
PIN: N/A
Carrier: Programmer
Posts: 50
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

yea
i was actually thinking about using the vector
but Hashtable sounds easier :S

but well...i can't even mess with the saving part right now because i have to fill up the socket part, cause it's only going to save when it receives some find of "email"...and i still don't have this app. but i can start on the loading part, that comes whenever the guy start the app...
But i'm still kidna confusing on how to use to load, if i save using the vector
i already read some about PersistenObject...and i know it's going to save in some kind of Long ID. but how am i going to load using the ListField, from this ID.

And i've seen a lot of those samples, but most don't explain that
i found the Contact, and that would be the most similar to my app, but it still using a bunch of classes i can't find about, or takes me an hour to find out that the class is already created in another file on the sample folder...
my app particularly don't need that many classes i THINK. the basic ones should do, because it's a metter of, save, load, and show and no more then that
and the save would have only "name" and "number" linked to each other...
so it's not like the contact table that has number, email, cellphone number, about etc etc
Offline  
Old 07-18-2008, 02:39 PM   #10 (permalink)
New Member
 
Join Date: Jun 2008
Model: 7290
PIN: N/A
Carrier: Cingular
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I suppose you can create your own Contact class if you feel that the provided ones are too complex for your specific project. It's not like your contact list will be interacting much with the native one from what I've read.

As for loading into your ObjectListField, once you recover your datastructure from the PersistentStore, simply iterate through it and insert each object into the ObjectListField.
Offline  
Old 07-18-2008, 02:47 PM   #11 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2008
Model: 7100T
PIN: N/A
Carrier: Programmer
Posts: 50
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

yea...i'm gonna try that and i'll post any news

and no, my contact list would not and CANT interact with the normal phonebook
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.