0

我需要从滚动中重置值,我已经实现了一个标签栏(在 Blackberry OS 6 中开发),在 VerticalFieldManager 中使用垂直滚动,但是当我选择另一个字段(标签)时,垂直滚动返回一个空指针,标签代码很好,所以我猜是因为第一个滚动事件保存了第一个字段(选项卡)中的项目长度,当长度小于第一个字段时给我一个空指针,我需要在完成滚动时从滚动中重置值,我看到了这个

(Mannager.NO_SCROLL_RESET)

但它已被弃用。我使用的是 OS 6,但标签栏必须适用于所有设备。

public class CustomizeTabbar extends MainScreen {

private int Resolucion;
VerticalFieldManager lista;
private AbsoluteFieldManager tab1Manager;
private AbsoluteFieldManager tab2Manager;
private AbsoluteFieldManager tab3Manager;
private AbsoluteFieldManager tab4Manager;
private AbsoluteFieldManager tab5Manager;  ///Detalle Nota

private AbsoluteFieldManager tabArea;
private String Token;

public CustomizeTabbar(int Res, String token) {

    Resolucion=Res;
    this.Token=token;

    try{
        ///Cabecera Tabbar
        HorizontalFieldManager htabbar= new HorizontalFieldManager(NO_HORIZONTAL_SCROLL|NO_VERTICAL_SCROLL|USE_ALL_WIDTH ){
            //define width
            public int getPreferredWidth()
            {
                if(Resolucion==1)
                    return 320;
                else
                    return 480;
            }
            //define height
            public int getPreferredHeight()
            {
                if(Resolucion==1)
                    return 25;
                else
                    return 36;

            }
            protected void sublayout( int maxWidth, int maxHeight )
            {
                super.sublayout(getPreferredWidth(), 
                        getPreferredHeight());
                setExtent(getPreferredWidth(), getPreferredHeight());
            }
        };

        final BitmapButtonField tab1= new BitmapButtonField(Bitmap.getBitmapResource("1notasactuales.png"),Bitmap.getBitmapResource("1notasactualesfocus.png"),FOCUSABLE);
        final BitmapButtonField tab2= new BitmapButtonField(Bitmap.getBitmapResource("1inasistencia.png"),Bitmap.getBitmapResource("1inasistenciafocus.png"),FOCUSABLE);
        final BitmapButtonField tab3= new BitmapButtonField(Bitmap.getBitmapResource("1Horario.png"),Bitmap.getBitmapResource("1HorarioFocus.png"),FOCUSABLE);
        final BitmapButtonField tab4= new BitmapButtonField(Bitmap.getBitmapResource("1record.png"),Bitmap.getBitmapResource("1recordfocus.png"),FOCUSABLE);
        LabelField spacer1 = new LabelField(" | ", LabelField.NON_FOCUSABLE);
         LabelField spacer2 = new LabelField(" | ", LabelField.NON_FOCUSABLE);
         LabelField spacer3 = new LabelField(" | ", LabelField.NON_FOCUSABLE);

        ///Controlador del Tabbar
        FieldChangeListener click=new FieldChangeListener() {

            public void fieldChanged(Field field, int context) {

                lista=null;
                if(tabArea!=null){
                try{
                    if(field==tab1)
                    {
                        delete(tabArea);
                        tabArea=NotasActualesDisplay();
                        add(tabArea);
                    }else 
                        if(field==tab2)
                        {
                            delete(tabArea);
                            tabArea = InasistenciaDisplay();
                            add(tabArea);
                        }else 
                            if(field==tab3)
                            {
                                delete(tabArea);
                                tabArea = HorarioDisplay();
                                add(tabArea);
                            }else
                                if(field==tab4)
                                {
                                    delete(tabArea);
                                    tabArea=RecordAcademicoDisplay();
                                    add(tabArea);
                                }
                }
                catch (Exception e) {
                    e.printStackTrace();
                    System.out.println(e.getMessage());
                }
                }

            }
        };
        tab1.setChangeListener(click);
        tab2.setChangeListener(click);
        tab3.setChangeListener(click);
        tab4.setChangeListener(click);

        htabbar.add(tab1);
        htabbar.add(spacer1);
        htabbar.add(tab2);
        htabbar.add(spacer2);
        htabbar.add(tab3);
        htabbar.add(spacer3);
        htabbar.add(tab4);

        Background bg = BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("2tabbar_pages.png"));
        htabbar.setBackground(bg);

        setTitle(htabbar);
        /////////
        tabArea = NotasActualesDisplay();
        add(tabArea);



    }catch (Exception e) {
        // TODO: handle exception
    }

}
  public AbsoluteFieldManager NotasActualesDisplay() {
    final VerticalFieldManager lista=new     VerticalFieldManager(Manager.VERTICAL_SCROLL|Manager.VERTICAL_SCROLLBAR|Manager.NO_SCROLL_RESET){
 /* Here I design the elements with JSON using FOR*/
    }
return tab1Manager;
 }
public AbsoluteFieldManager InasistenciaDisplay() {
    VerticalFieldManager(Manager.VERTICAL_SCROLL|Manager.VERTICAL_SCROLLBAR|Manager.NO_SCROLL_RESET){
 /* Here I design the elements with JSON using FOR*/
    }
return tab2Manager;
 }
public AbsoluteFieldManager HorarioDisplay() {
    VerticalFieldManager(Manager.VERTICAL_SCROLL|Manager.VERTICAL_SCROLLBAR|Manager.NO_SCROLL_RESET){
 /* Here I design the elements with JSON using FOR*/
    }
 }
return tab3Manager;    
 }
4

0 回答 0