gpt4 book ai didi

java - BlackBerry 上 ListField 行中的文本换行

转载 作者:行者123 更新时间:2023-12-02 08:25:25 24 4
gpt4 key购买 nike

如何在 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.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());

希望这能在某些地方帮助你

关于java - BlackBerry 上 ListField 行中的文本换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4624262/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com