BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 09-10-2007, 05:23 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8800
PIN: N/A
Carrier: GPRS
Posts: 68
Post Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation A problem of list item icon

Please Login to Remove!

Hi, everyone:

I want to show an icon for each list item, how should I do in JDE 4.2.1?
For example, when we read massage or SMS , we can see the icons , time ,phone numbers, and the subjects of each massage, how can we do this ? It's easy to write words in list by List.append, but it's difficult for the icons. We know the RIM can do this , but I don't know whether we can do this.

Thanks all!
Offline  
Old 09-10-2007, 08:31 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi streamh,

Quote:
Originally Posted by streamh View Post
Hi, everyone:

I want to show an icon for each list item, how should I do in JDE 4.2.1?
For example, when we read massage or SMS , we can see the icons , time ,phone numbers, and the subjects of each massage, how can we do this ? It's easy to write words in list by List.append, but it's difficult for the icons. We know the RIM can do this , but I don't know whether we can do this.

Thanks all!
To create a list with icon, the ListField class is needed and the ListFieldCallback interface must be implemented. Then draw your icon using drawListRow() method of your ListFieldCallback implemention.

Hope this will Help!

Cheers,
ARIF
Offline  
Old 09-12-2007, 02:57 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8800
PIN: N/A
Carrier: GPRS
Posts: 68
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,ARIF:
I have searched the drawListRow() method in the ListFieldCallback, but the API has a simple description of it. It just explains the parameters of the method and does not contain any demo.
Could you show some demo about this?Thank you very much for your help!
Offline  
Old 09-12-2007, 03:26 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi streamh,

Quote:
Originally Posted by streamh View Post
Hi,ARIF:
I have searched the drawListRow() method in the ListFieldCallback, but the API has a simple description of it. It just explains the parameters of the method and does not contain any demo.
Could you show some demo about this?Thank you very much for your help!
Here is a sample code with implementation of ListFieldCallback:
Code:
private class ListCallback implements ListFieldCallback {
    private Bitmap LIST_IMAGE = Bitmap.getBitmapResource("list.gif");
    private Vector listElements = new Vector();
    public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
        String text = (String)listElements.elementAt(index);            
        g.drawBitmap(0, y, LIST_IMAGE.getWidth(), LIST_IMAGE.getHeight(), LIST_IMAGE, 0, 0);
        g.drawText(text, 50, y, 0, w);
    }
    public Object get(ListField list, int index) {
        return listElements.elementAt(index);
    }
    public int indexOfList(ListField list, String p, int s) {            
        return listElements.indexOf(p, s);
    }
    public int getPreferredWidth(ListField list) {
        return Graphics.getScreenWidth();
    }
    public void insert(String toInsert, int index) {
        listElements.insertElementAt(toInsert, index);
    }
}
And add the following code where you do like to add the list on your screen:
Code:
ListField list = new ListField();
ListCallback callback = new ListCallback();
list.setCallback(callback);
for (int index=0; index<5; index++) {
    list.insert(index);
    callback.insert("Row"+index, index);
}
add(list);
Enjoy!
ARIF
Offline  
Old 09-13-2007, 01:12 AM   #5 (permalink)
Thumbs Must Hurt
 
Rose's Avatar
 
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
String text = (String)listElements.elementAt(index);
g.drawBitmap(0, y, LIST_IMAGE.getWidth(), LIST_IMAGE.getHeight(), LIST_IMAGE, 0, 0);
g.drawText(text, LIST_IMAGE.getWidth()+10, y, 0, w);
}


This will allows to display next next to the icon otherwise sometimes the text will override the icon.
Offline  
Old 09-13-2007, 01:22 AM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

you are right! i've used fixed space after drawing. Anyway, Hope! now you are expert to fix your problem.
Offline  
Old 09-13-2007, 01:54 AM   #7 (permalink)
Thumbs Must Hurt
 
Rose's Avatar
 
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by arifzaman View Post
you are right! i've used fixed space after drawing. Anyway, Hope! now you are expert to fix your problem.
Actually i just gave out a idea and it was not my post at all.
Offline  
Old 09-14-2007, 12:32 AM   #8 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8800
PIN: N/A
Carrier: GPRS
Posts: 68
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much for all you help!
It's a greate answer to me!
I'm very happy!
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.