BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 06-28-2010, 04:30 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Child list and expand/collapse in ListField

Please Login to Remove!

How to display child list in ListField? Is there any way to expand and collapse the child list in ListField?
Offline  
Old 06-28-2010, 09:48 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

Have you looked at TreeField?
Offline  
Old 06-29-2010, 09:30 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, I tried TreeField also.

I found a good example of TreeField
h**p://stackoverflow.com/questions/1038048/blackberry-treefield-with-checkboxes

I don't need checkboxes. So, I removed checkboxes but the problem is loading the child list dynamically and when I click one of the child field, it should open another screen. How to capture the click event for child field and navigate to another screen?

Also if I click any parent field, it should expand the child list. and if there is no child list, clicking the parent field should open another screen.

what is solution of this problem?

And also Is there any way to solve this using ListField?

Last edited by romah : 06-29-2010 at 09:48 AM.
Offline  
Old 06-29-2010, 10:29 AM   #4 (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

OK, now you've lost me.

What does expanding a child list have to do with opening another screen?

If you want to open another screen, override navigationClick(), look at the selected item, and call your screen from there.
Offline  
Old 06-29-2010, 11:01 AM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, here is my requirement.

-CustomerInfo
-Address
|---DepartAddress
|---DestAddress
|---Stops
-History
|---Jobs Accepted
|---Jobs Rejected
-Misc

-->When I click CutomerInfo, since it has no child, it should display the customers information either by expanding the gap between CustomerInfo and Address, or display the customer information in another screen. I prefer to display by expanding the gap.

-->When I click Address, since it has child fields, it should expand to show its child fields. Now when I click DepartAddress, it should display departure address information either by expanding the gap between DepartAddress and DestAddress, or display the destination address info in another screen. I prefer to display by expanding the gap.
When I again click Address, the expanded list should be hidden (i.e., collapse to Address)

What is the way to handle this problem?

Last edited by romah : 06-29-2010 at 11:02 AM.
Offline  
Old 06-29-2010, 01:02 PM   #6 (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

TreeField is your best answer, IMHO. That's where I would start.
Offline  
Old 06-29-2010, 04:23 PM   #7 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've hardcoded the list values and the functionality is ok.

But the indentation is not good.
I also need to set the proper color.

Would you please help me?


Here is the code:

import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.TreeField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.component.TreeFieldCallback;
import net.rim.device.api.ui.Field;

public class TreeViewExample extends MainScreen {

String addr = new String("Address");
String history = new String("History");
String custInfo = new String("CustomerInfo");
String misc = new String("Misc");
String deptAddr = new String("DepartAddress");
String destAddr = new String("DestAddress");
String stopAddr = new String("StopAddress");
String jobAccept = new String("JobAccepted");
String jobReject = new String("JobRejected");

public TreeViewExample() {
TreeCallback myCallback = new TreeCallback();
TreeField myTree = new TreeField(myCallback, Field.FOCUSABLE);

int node1 = myTree.addChildNode(0, addr);
int node2 = myTree.addChildNode(0, custInfo);
int node3 = myTree.addChildNode(0, history);
int node4 = myTree.addChildNode(0, misc);
int node11 = myTree.addChildNode(node1, deptAddr);
int node12 = myTree.addChildNode(node1, destAddr);
int node13 = myTree.addChildNode(node1, stopAddr);
int node31 = myTree.addChildNode(node3, jobAccept);
int node32 = myTree.addChildNode(node3, jobReject);
int node121 = myTree.addChildNode(node11, "New York");

myTree.setExpanded(node1, false);
myTree.setExpanded(node3, false);

add(myTree);
}

public class TreeCallback implements TreeFieldCallback {
public void drawTreeItem(TreeField treeField, Graphics graphics, int node, int y, int width, int indent) {
String item = (String) treeField.getCookie(node);
graphics.drawText(item, indent, y);
}
}
}
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.