Java BlackBerry上列表字段行中的文本换行
如何在ListField行中包装文本?我在左侧显示图像,在右侧显示文本。一些较长的文本从ListField行中消失,我希望它被包装,而不是被切断。我也面临同样的问题,因为我的要求与您的要求相同,但如果您不使用图像,但仍然希望使用自定义标签字段来传递一些参数,您可以使用我的方式Java BlackBerry上列表字段行中的文本换行,java,blackberry,Java,Blackberry,如何在ListField行中包装文本?我在左侧显示图像,在右侧显示文本。一些较长的文本从ListField行中消失,我希望它被包装,而不是被切断。我也面临同样的问题,因为我的要求与您的要求相同,但如果您不使用图像,但仍然希望使用自定义标签字段来传递一些参数,您可以使用我的方式 import net.rim.device.api.system.Bitmap; import net.rim.device.api.ui.Color; import net.rim.device.api.ui.Field
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Keypad;
import net.rim.device.api.ui.component.LabelField;
public class MyCustomSubscriptionLabelField extends LabelField {
private Bitmap image = null;
private String customName = null;
private String key;
private String programName, startTime;
// Edited by vivek on 2010-11-18 to convert Basic Tv as Live tv i.e mapping
public MyCustomSubscriptionLabelField(String key, String customName,
long style) {
super("", FOCUSABLE);
if (customName == null)
this.customName = key;
else
this.customName = customName;
this.key = key;
}
public MyCustomSubscriptionLabelField(String programName, String startTime,
String customName, long style) {
super("", FOCUSABLE);
this.programName = programName;
this.startTime = startTime;
}
public void setText(String text, int offset, int length) {
// super.setText(customName, image.getWidth(), customName.length());
super.setText(text);
}
public void paint(Graphics graphics) {
super.paint(graphics);
}
public String getCustomName() {
return customName;
}
public String getKey() {
return key;
}
protected boolean navigationClick(int status, int time) {
fieldChangeNotify(0);
return true;
}
protected boolean keyChar(char character, int status, int time) {
if (character == Keypad.KEY_ENTER) {
fieldChangeNotify(0);
return true;
}
return super.keyChar(character, status, time);
}
public void setProgramName(String programName) {
this.programName = programName;
}
public String getProgramName() {
return programName;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getStartTime() {
return startTime;
}
}
要使用此自定义标签字段类,请使用setText设置任何长文本
customSubscriptionLabelField[j]=
new CustomSubscriptionLabelField("","Value tht u want to pass and retrive",style);
customSubscriptionLabelField[j].setText("Any Long text will be wrapped to new line ",0,text.length());
希望这能在某些地方帮助你嘿,我又找到了一个解决问题的方法。 将图像添加到hfm1 将labelfield添加到hfm2 现在将hfm1和hfm2添加到vfm
现在将此vfm添加到屏幕上,这将像一个带有图像和文本的标签字段,很可能符合我们的目的我在blackberry开发者支持论坛上找到了这个问题的答案,并认为它可能对您有用:
谢谢vivek对您的帮助。我正在实施它。如果它对您有帮助,请让您知道我是否会将它标记为已回答,如果您使用文本自定义LabelField实施pic,请让我知道。我找到了一个简单的解决方案。在label字段中,使用LabelField。使用所有高度,在布局位置,它相应地。它工作良好。你能给我一个示例代码吗?因为在我的应用程序中,Im使用了很多管理者,所以很难找出问题的原因。