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


Apple Vintage m-20 stapler picture

Apple Vintage m-20 stapler

$15000.00



2023 vintage apple art lithograph illustration notebook picture

2023 vintage apple art lithograph illustration notebook

$16.50



Vintage Wooden Apple  hand carved with stem  wood grain 4

Vintage Wooden Apple hand carved with stem wood grain 4"x 3"

$12.77



Vintage Hocking Valley Wine Grape Crusher Grinder Juicer Fruit Cider Apple Press picture

Vintage Hocking Valley Wine Grape Crusher Grinder Juicer Fruit Cider Apple Press

$1100.00



VINTAGE PRINTING LETTERPRESS PRINTERS BLOCK CUT Whole Apple with Stem Fruit picture

VINTAGE PRINTING LETTERPRESS PRINTERS BLOCK CUT Whole Apple with Stem Fruit

$12.00



7 - Vintage Shape Teacher Note Pads, apple fish flower frog lined and plain picture

7 - Vintage Shape Teacher Note Pads, apple fish flower frog lined and plain

$5.99







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