スクロールから値をリセットする必要があります。VerticalFieldManager で垂直スクロールを使用してタブバー (Blackberry OS 6 で開発) を実装しましたが、別のフィールド (タブ) を選択すると、垂直スクロールが nullpointer を返します。タブ コードは問題ありません。 、最初のスクロールイベントが最初のフィールド(タブ)からアイテムの長さを保存したためだと思います。長さが最初のものよりも短い場合、nullpointerが返されます。スクロールが終了したら、スクロールから値をリセットする必要があります。これ
(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;
}