【问题标题】:J2ME LWUIT - Error showing outside screen labels on scrollJ2ME LWUIT - 在滚动时显示外部屏幕标签时出错
【发布时间】:2012-01-24 07:22:59
【问题描述】:

我正在使用 LWUIT 开发 J2ME 应用程序。 我需要显示 10 个值,每个值都带有 Label

类似这样的:

Label1       Value1
Label2       Value2
Label3       Value3
Label4       Value4
............
LabelN       ValueN

我为每个“行”使用 1 个Container,为每个“行容器”使用一个大的Container

我的问题是屏幕外的“行”。当我使用滚动时,最后 4 对 Label+value 没有显示

我不知道为什么。 有人可以解决这个问题吗?

这是我的代码:

this.setLayout(new BorderLayout());
PromotionMonitorDTO promotionMonitorDTO = Cloud.getPromotionMonitor();
Utils utils = new Utils();
Font f = Font.getBitmapFont("movSmall");
Container cellContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
Container rowContainer = new Container(new BoxLayout(BoxLayout.X_AXIS));

//FIRST PAIR///////////////////////

String stringValue = utils.calendarToShorString(promotionMonitorDTO.getLastUpdate());
Label valor = new Label(LanguageManager.getText("LastUpdate"));
valor.getStyle().setFont(f);        
rowContainer.addComponent(valor);  
valor = new Label(LanguageManager.getText(stringValue));
valor.getStyle().setFont(f);
rowContainer.addComponent(valor);        
cellContainer.addComponent(rowContainer);
rowContainer = new Container(new BoxLayout(BoxLayout.X_AXIS));

//SECOND PAIR///////////////////////

stringValue = String.valueOf(promotionMonitorDTO.getInitialTarget());
valor = new Label(LanguageManager.getText("InitialTarget"));
valor.getStyle().setFont(f);        
rowContainer.addComponent(valor);  
valor = new Label(LanguageManager.getText(stringValue));
valor.getStyle().setFont(f);
rowContainer.addComponent(valor);   
cellContainer.addComponent(rowContainer);

////////8 MORE PAIRS////////////////////

this.addComponent(BorderLayout.NORTH, cellContainer);

【问题讨论】:

    标签: java-me lwuit


    【解决方案1】:

    我终于解决了。

    我删除了第二个容器,我将表单的布局更改为BoxLayout(BoxLayout.Y_AXIS),并将所有“行容器”添加到表单中,

    通过这些更改,我具有相同的图形功能,并且滚动正在工作。

    我必须删除问题? o 留给别人?

    【讨论】:

    • 在问题 48 小时前不能接受自我回答。那么这样做是合适的。
    【解决方案2】:

    也许您必须“冻结”Form 并使其不可滚动。使用Form.setScrollable(false) 设置Form 不可滚动,并使BorderLayout 的中心/北Container 可滚动。尝试这样做。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-12
      相关资源
      最近更新 更多