BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 08-21-2009, 05:58 PM   #1
brendanmc25
Knows Where the Search Button Is
 
Join Date: Aug 2009
Model: 9530
PIN: N/A
Carrier: o2
Posts: 35
Default Please put me out of my misery

Please Login to Remove!

I have been trying to research and understand the concept of listfield, objestlistfield andd listfieldcallback.

I currently have a objectlistfield showing results from a search with http connection. when i get the results it's in one big string, i split the string and recreate the objects, basically 5 string variables, I then have the toString displayed in objectlistfield for each object(all 5 variables printed). I have been trying to learn how to JUST get the name variable showing in the objectlistfield. I know I could do this with the .tostring and just display one variable for each object but i need the other string variables going with it as when the object is selected I go on to re-create the object which is an extension of screen so i can see all the variables in a screen.

My last 5 hours have been wasted attempting to extend objectlistview and then override it's drawlistrow method which i use to access variables from the class vector and then drawText for just one of these of these variables and then hopefully a picture. have I misunderstood the concept? I'm thinking that the objectListField row is created by the drawlistrow method so whatever i put in that method will be put in the row, is that right/wrong?

Please help a desperate man!
Offline  
Old 08-21-2009, 07:04 PM   #2
ptys
Knows Where the Search Button Is
 
Join Date: Jul 2008
Model: none
PIN: N/A
Carrier: none
Posts: 26
Default

Try something like this

Code:
class MyGrid extends ListField implements ListFieldCallback {

    private MyData[] data;

    public MyGrid(MyData[] data) {
        setCallback(this);
        this.data = data;
    }

    public void drawListRow(ListField listField, Graphics g, int index, int y, int width) {
    	MyData row = (MyData) get(listField, index);
        // draw some stuff
        Bitmap b = Bitmap.getBitmapResource(row.icon);
        g.drawBitmap(0, y, 16, 16, b, 0, 1);
        int indent = 24;
        g.drawText(row.string, indent, y, Graphics.ELLIPSIS, width - indent);
    }

    public Object get(ListField listField, int index) {
        return data[index];
    }

    public int getPreferredWidth(ListField listField) {
        return Display.getWidth();
    }

    public int indexOfList(ListField listField, String prefix, int start) {
        return getSelectedIndex();
    }

    public int getSize() {
        return (data != null) ? data.length : 0;
    }
    
    class MyData {
    	String string;
    	String icon;
    }
}
Offline  
Old 08-22-2009, 08:00 AM   #3
brendanmc25
Knows Where the Search Button Is
 
Join Date: Aug 2009
Model: 9530
PIN: N/A
Carrier: o2
Posts: 35
Default thank you

your post was exactly the concept i was ooking for and i have almost got it, I just don't get the image on screen even though it's there, I think i'll get it!

Last edited by brendanmc25; 08-22-2009 at 08:31 AM..
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


2x Memory Foam Armrest Cushion Pads Elbow Arm Rest Cover Chair Armrest Pads picture

2x Memory Foam Armrest Cushion Pads Elbow Arm Rest Cover Chair Armrest Pads

$14.71



64GB Rechargeable LCD Digital Audio Sound Voice Recorder Dictaphone MP3 Player picture

64GB Rechargeable LCD Digital Audio Sound Voice Recorder Dictaphone MP3 Player

$29.49



SKECHERS WORK Men's, Electrical Hazard Safe, Air Cooled Memory Foam Boots picture

SKECHERS WORK Men's, Electrical Hazard Safe, Air Cooled Memory Foam Boots

$89.99



Automatic Wrist Blood Pressure Monitor BP Cuff Gauge Machine Tester with Memory picture

Automatic Wrist Blood Pressure Monitor BP Cuff Gauge Machine Tester with Memory

$15.68



32G Voice Activated Mini Spy Digital Sound Audio Recorder Dictaphone MP3 Player picture

32G Voice Activated Mini Spy Digital Sound Audio Recorder Dictaphone MP3 Player

$20.99



American Crafts We R Memory Keepers CINCH - BOOK BINDING TOOL - ROUND 71050-9 picture

American Crafts We R Memory Keepers CINCH - BOOK BINDING TOOL - ROUND 71050-9

$99.74







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