包含列表lwuit时,表单无法滚动

时间:2013-01-25 09:12:39

标签: list scroll lwuit

这是我的代码:

public Form getMenuForm()
{
    if ( menuForm == null )
    {
        Form menuForm = new Form( "Tracking Main Menu" );
        menuForm.setLayout( new BoxLayout( BoxLayout.Y_AXIS ) );
        menuForm.setScrollable( true );
        menuForm.setScrollableY( true );
        menuForm.addComponent( this.getMenuList() );
        for(int i=0;i<30;i++)
        {
            Label lblTest = new Label("hello guys");
            menuForm.addComponent( lblTest );
        }
        menuForm.addCommand( new Command( "Exit" ) );
        menuForm.setTransitionOutAnimator( CommonTransitions.createSlide( CommonTransitions.SLIDE_HORIZONTAL, true,
            200 ) );
        menuForm.addCommandListener( this );
    }
    return menuForm;
}

 public List getMenuList()
{
    String[] menuItems = { "Find Person", "Person Registration", "Message", "Setting" };
    if ( menuList == null )
    {
        menuList = new List( menuItems );
        menuList.setListCellRenderer( new DefaultListCellRenderer( false ) );
        menuList.setSmoothScrolling( true );
        menuList.setFixedSelection( List.FIXED_NONE );
        menuList.addActionListener( this );
    }
    return menuList;
}

我只能选择4个列表选项,而我无法向下滚动以查看屏幕底部。我在这里想念一下,请帮助我......

2 个答案:

答案 0 :(得分:2)

您需要将menuForm设置为可滚动的false,并让列表的可滚动性接管。您将滚动嵌套在另一个中,这会产生糟糕的用户体验。

答案 1 :(得分:0)

也许你需要这样做:

menuList.setScroable(true);