黑莓 - 线路未显示

发布于 2024-08-13 13:08:17 字数 522 浏览 4 评论 0原文

我的 EditField 遇到问题。 我在“Horizo​​ntalFieldManager”下使用此代码创建了一个 EditField

EditField nameEditLabel = new EditField (EditField.FOCUSABLE 
    | EditField.NO_NEWLINE | EditField.FIELD_RIGHT);
nameEditLabel.setMaxSize(25);
nameEditLabel.setMargin(50, 0, 0, 80);
horizontalFldManager.add(nameEditLabel);

现在的问题是,在屏幕上,它不显示字段的行。就像,基本上一个字段在其他平台控件中包含“名称:----------------------”这样的行,这在屏幕上没有显示。这里有什么问题呢? API 支持是默认的吗?如果不是,我该如何解决?

注意:只有当我在字段上写东西时才会创建此行。

谢谢。

I am having a problem with EditField.
I have created an EditField using this code under a "HorizontalFieldManager".

EditField nameEditLabel = new EditField (EditField.FOCUSABLE 
    | EditField.NO_NEWLINE | EditField.FIELD_RIGHT);
nameEditLabel.setMaxSize(25);
nameEditLabel.setMargin(50, 0, 0, 80);
horizontalFldManager.add(nameEditLabel);

Problem now is, On the screen, it doesn't show the line of the field. Something like, basically a Field contain "Name: ----------------------" such line in other platform controls, which is not showing here on the screen. What is the problem here? Is it default in API support? If no, how do i resolve it?

Note: This line is getting created only when i write something on the field.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

囍笑 2024-08-20 13:08:17

如果您希望在 EditField 为空的情况下使用此“----”,请扩展​​它以实现检查值逻辑:

class LabelFieldEmpty extends EditField {
 String mEmptyText = "";

 public LabelFieldEmpty(long style) {
  super(style);
 }

 public void setEmptyText(String emptyText) {
  mEmptyText = emptyText;
 }

 public String getEmptyText() {
  return mEmptyText;
 }

 protected boolean keyChar(char key, int status, int time) {
  if (null != mEmptyText)
   if (getText().equalsIgnoreCase(mEmptyText)) {
    setText(String.valueOf(key));
    return true;
   }
  return super.keyChar(key, status, time);
 }

 protected void fieldChangeNotify(int context) {
  if (null != mEmptyText)
   if (!getText().equalsIgnoreCase(mEmptyText))
    if (getText().equalsIgnoreCase("")) {
     setText(mEmptyText);
     setCursorPosition(0);
    }
  super.fieldChangeNotify(context);
 }
}

使用示例:

class Scr extends MainScreen {

 public Scr() {
  String label = "Name:";
  String empty = "-------------------------";
  int maxChars = 25;
  long style = EditField.FOCUSABLE | EditField.NO_NEWLINE
    | EditField.FIELD_RIGHT;
  LabelFieldEmpty nameEdit = new LabelFieldEmpty(style);
  nameEdit.setLabel(label);
  nameEdit.setMaxSize(maxChars);
  nameEdit.setMargin(50, 0, 0, 80);
  nameEdit.setEmptyText(empty);
  add(nameEdit);
 }
}

If you want to have this "----" in case EditField is empty, extend it to implement check value logic:

class LabelFieldEmpty extends EditField {
 String mEmptyText = "";

 public LabelFieldEmpty(long style) {
  super(style);
 }

 public void setEmptyText(String emptyText) {
  mEmptyText = emptyText;
 }

 public String getEmptyText() {
  return mEmptyText;
 }

 protected boolean keyChar(char key, int status, int time) {
  if (null != mEmptyText)
   if (getText().equalsIgnoreCase(mEmptyText)) {
    setText(String.valueOf(key));
    return true;
   }
  return super.keyChar(key, status, time);
 }

 protected void fieldChangeNotify(int context) {
  if (null != mEmptyText)
   if (!getText().equalsIgnoreCase(mEmptyText))
    if (getText().equalsIgnoreCase("")) {
     setText(mEmptyText);
     setCursorPosition(0);
    }
  super.fieldChangeNotify(context);
 }
}

Example of use:

class Scr extends MainScreen {

 public Scr() {
  String label = "Name:";
  String empty = "-------------------------";
  int maxChars = 25;
  long style = EditField.FOCUSABLE | EditField.NO_NEWLINE
    | EditField.FIELD_RIGHT;
  LabelFieldEmpty nameEdit = new LabelFieldEmpty(style);
  nameEdit.setLabel(label);
  nameEdit.setMaxSize(maxChars);
  nameEdit.setMargin(50, 0, 0, 80);
  nameEdit.setEmptyText(empty);
  add(nameEdit);
 }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文