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

1pc 4 ways Electronic Switch Lamp Lighting On-Off Load= AC110V 450W x3 Taiwan
$4.9
1pc 4 ways Electronic Switch Lamp Lighting On-Off Load= AC110V 450W x3 Taiwan picture(6) Schmersal AZ 15 ZVK Interlock Switch IP67 IEC947-5-1 230V 4A AC-15 VDE0660
$80.0
(6) Schmersal AZ 15 ZVK  Interlock Switch IP67 IEC947-5-1 230V 4A AC-15 VDE0660 pictureEFS-D Foot Switch 10A 250VAC Foot Petal Highly New
$35.0
EFS-D Foot Switch 10A 250VAC Foot Petal Highly New pictureSTI MC-K1 IP 67 Actuator Interlock Switch Safety NEW
$50.0
STI MC-K1 IP 67 Actuator Interlock Switch Safety NEW picture151-7Z-06K Sentrol Industrial Interlock Guard Switch 100V 120VAC 28Vdc LR89176
$30.0
151-7Z-06K Sentrol Industrial Interlock Guard Switch 100V 120VAC 28Vdc LR89176 picture






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