BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 04-13-2010, 09:44 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2010
Model: 7100T
PIN: N/A
Carrier: job
Posts: 15
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default word wrap

Please Login to Remove!

i implement list field but i have long text field how to make word wrap format in paint methode .
my code here

import java.util.Vector;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.DrawStyle;
class ListCallBack implements ListFieldCallback
{
private Vector listElements = new Vector();
private Vector listElements1 = new Vector();
private Vector listElements2 = new Vector();
private Vector listImg = new Vector();
int width,height;


public void drawListRow(ListField list, Graphics g, int index, int y, int w)
{
String Name = (String)listElements.elementAt(index);
String dateofbirth = (String)listElements1.elementAt(index);
String status = (String)listElements2.elementAt(index);


Bitmap image=(Bitmap)listImg.elementAt(index);
height=image.getHeight()+5;
width=Display.getWidth();

//g.drawRect(0,0,width,20);
int imgwidsize=image.getWidth();
int textwid=(imgwidsize)+10;
g.setFont(g.getFont().derive(Font.PLAIN,14));
int fonthight=g.getFont().getHeight();
int z=y+5;
int fhight=z+fonthight;
int totalwidth=width-imgwidsize;
// System.out.println("width="+totalwidth+"textwid"+N ame.length()) ;


g.drawBitmap(0,z,image.getWidth(),image.getHeight( ),image,0,0);
g.drawText("Name : "+Name,textwid,z,DrawStyle.LEADING | DrawStyle.ELLIPSIS, w-textwid);
g.drawText("Dob : "+dateofbirth,textwid,fhight,DrawStyle.LEADING | DrawStyle.ELLIPSIS, w-textwid);
g.drawText("Status : "+status,textwid,fonthight+fhight,DrawStyle.LEADIN G | DrawStyle.ELLIPSIS, w-textwid);
g.setColor(Color.BLACK);
g.drawRect(0,y+1,width,1);
}
public Object get(ListField list, int index)
{
return listImg.elementAt(index);
}

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

public void insert(String toInsert ,int index)
{
listElements.insertElementAt(toInsert,index);
}

public void insert1(String toInsert ,int index)
{
listElements1.insertElementAt(toInsert,index);
}
public void insert2(String toInsert ,int index)
{
listElements2.insertElementAt(toInsert,index);
}

public void insertimg(Bitmap toInsertmap ,int index)
{
listImg.insertElementAt(toInsertmap,index);
}

public void erase()
{
//listElements.removeAllElements();
}

public int indexOfList(ListField listField, String prefix, int start) {
return listImg.indexOf(listField);

}
public int size() {
return listImg.size();
}



}


please help code via.
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

VINTAGE DEC Digital M8043 5013216F1 Q-Bus interface PCB 4 PORT
$39.99
VINTAGE DEC Digital M8043 5013216F1 Q-Bus interface PCB 4 PORT pictureVintage Digital DEC M3106 Line SYNC MUX Board
$29.99
Vintage Digital DEC M3106 Line SYNC MUX Board pictureHand Glove Vintage Mannequin General Porcelain Sz 8 HH Trenton NJ Dec. 15, 1971
$55.0
Hand Glove Vintage Mannequin General Porcelain Sz 8 HH Trenton NJ Dec. 15, 1971 pictureDated DEC 1910: LARGE Vintage Brass Pressure Gauge By ASHCROFT, Steampunk Part
$37.99
Dated DEC 1910: LARGE  Vintage Brass Pressure Gauge By ASHCROFT, Steampunk Part pictureDated DEC 1910: LARGE Vintage Brass Pressure Gauge By ASHCROFT, Steampunk Part
$37.99
Dated DEC 1910: LARGE  Vintage Brass Pressure Gauge By ASHCROFT, Steampunk Part picture






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