LWUIT scroll jumping issue

跟風遠走 提交于 2019-12-23 11:48:51

问题


I need to show the only component on the form - HTMLComponent. Reaching the bottom of the form/component while vertical scrolling scroll bar jumps back to the top of the form. I need to prevent this.

I've tried to turn on/off scrolling on the form and HTMLComponent but anyway if there's a scroll bar - it will return to the top from the bottom. Also I've tried border and box layouts and additional container for HTMLComponent - no use.

Any ideas how to prevent such scrolling issue?


回答1:


Try this (it works for me - LWUIT 1.5):

htmlComponent.getComponentForm().setCyclicFocus(false);

If you get a NullPointerException, call it after adding to the HtmlComponent to a form.




回答2:


If you want to get rid of the bottom/top jump scroll, you can use

form.setCyclicFocus(false)




回答3:


You should stick with border layout and place the HTML component in the center for this particular use case. You can disable form scrolling since the HTML component is indeed scrollable by default:

form.setScrollable(false);



回答4:


HTMLComponent is itself scrollable

to prevent scrolling

setScrollable(false);

for horizontal scroll off

setScrollableX(false);

hope this will solve your issue




回答5:


...or, you can paste this code on your Form class

public void keyPressed(int keyCode) {
    int tecla = Display.getInstance().getGameAction(keyCode);

    if(tecla == 8){
        //if hit ENTER or principal key in mobile keyboard
    }else if(tecla == 6){//down key
        if(this.list_component_name.getSelectedIndex() < this.list_component_name.size() - 1)
            this.list_component_name.setSelectedIndex(this.lista_bodegas.getSelectedIndex() + 1);
    }else if(tecla == 1){//up key
        if(this.list_component_name.getSelectedIndex() > 0)
            this.list_component_name.setSelectedIndex(this.list_component_name.getSelectedIndex() - 1);
    }
}

That's also work for me




回答6:


form.serScrollable(false) or form.setCyclicFocus(false) didn't work for me. I have a form and just a single HTMLComponent in it.
The problem is in HTMLComponent itself and disabling focus of the form won't affect it.




回答7:


You can try with making the whole component focusable which might help in scrolling in a proper way. Along with this you should add your html component in Boderlayout.center of form and make form scrollable true and cyclic focus false.




回答8:


In LWUITImplementation we have function getDragPathTime(). This javaDoc about this function:

 /**
 * Indicates what drag points are valid for the drag speed calculation.
 * Points that are older then the current time - the path time are ignored
 * 
 * @return the relevance time per point
 */

I also was problem especially in devices with OS S-60 Nokia. Lists was jumped from buttom to top. i solved this problem by change the return value. I change the value to 600( from 200). this occurs to fewer sampling and prevent the "jump".



来源:https://stackoverflow.com/questions/5818255/lwuit-scroll-jumping-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!