简体   繁体   English

LWUIT列表的运行速度非常慢

[英]LWUIT List works terribly slow

I've faced with the well-known problem in LWUIT. 我遇到了LWUIT中众所周知的问题。 My list component with the checkbox renderer scrolls very slow. 我的带有复选框渲染器的列表组件滚动非常慢。 If to test my application on emulator it runs quite smoothly (nevertheless I see CPU utilization splashes up to 60% during scroll action), but if to run it on mobile phone it takes a couple of seconds between focus movements. 如果要在模拟器上测试我的应用程序,它将运行得非常平稳(尽管我看到滚动操作期间CPU利用率会高达60%),但是如果要在手机上运行它,则焦点移动之间需要花费几秒钟的时间。

There's a code of renderer: 有一个渲染器代码:

public class CheckBoxMultiselectRenderer extends CheckBox implements ListCellRenderer {

public CheckBoxMultiselectRenderer() {
    super("");
}

//override
public void repaint() {
}

public Component getListCellRendererComponent(List list, Object value, 
 int index,boolean isSelected) {
    Location loc = (Location)value;
    setText(loc.getLocationName());
    setFocus(isSelected);
    setSelected(loc.isSelected());

    return this;
}

public Component getListFocusComponent(List list) {
    setText("");
    setFocus(true);
    getStyle().setBgTransparency(Consts.BG_TRANSPARENCY);
    return this;
}
}

that's the code of my form containing the list: 那是我包含列表的表单的代码:

protected void createMarkup() {
    Form form = getForm();
    form.setLayout(new BorderLayout());
    form.setScrollable(false);

    Label title = new Label("Choose location zone:");
    title.getStyle().setMargin(5, 5, 0, 0);
    title.getStyle().setBgTransparency(Consts.BG_TRANSPARENCY);
    title.setAlignment(Component.CENTER);

    form.addComponent(BorderLayout.NORTH, title);

    list = new List(StateKeeper.getLocationsAsList());
    list.setFixedSelection(List.FIXED_NONE_CYCLIC);
//        list.setSmoothScrolling(true);
    list.getStyle().setBgTransparency(0);
    list.setListCellRenderer(new CheckBoxMultiselectRenderer());
    list.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent ae){
//                List l = (List)ae.getSource();
//                l.requestFocus();
//                l.setHandlesInput(true);
            Location selItem = (Location)list.getSelectedItem();
            selItem.setSelected(!selItem.isSelected());
        }
    });

    form.addComponent(BorderLayout.CENTER, list);
}

I would be very thankful for any help! 我将非常感谢您的帮助!

We must be so carefull building lwuit List . 我们必须如此谨慎地建立List If we have made something wrong they can work worse than expected. 如果我们做错了,它们的工作可能会比预期的要差。 I recommend you to take a look on this 我建议你看看这个

LWUIT Blog ListRender LWUIT博客ListRender

You can also rewrite your paint method. 您也可以重写绘画方法。 You list's speed will be increased. 您列表的速度将会提高。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM