1

我是黑莓新手,我有一个问题,我连续有 3 个列表字段,例如

[ - - - - 一二三 - ]

但是当我滚动单个时,每个滚动!,当焦点滚动时如何限制其他滚动?

编辑

// ListFields
HorizontalFieldManager hfmMain = new HorizontalFieldManager();

HorizontalFieldManager hfmFist = new HorizontalFieldManager(FIELD_LEFT);
hfmFist.add(myListView);

HorizontalFieldManager hfmSecond = new HorizontalFieldManager();
hfmSecond.add(hizabListView);

HorizontalFieldManager hfmThird = new HorizontalFieldManager();
hfmThird.add(paraListView);

hfmMain.add(hfmFist);
hfmMain.add(hfmSecond);
hfmMain.add(hfmThird);

add(hfmMain);

在此处输入图像描述

4

2 回答 2

1

您在一个屏幕管理器中有多个列表字段,当您向下滚动并选择此管理器时,滚动事件将发送到所有这些字段。所有这些都在同时滚动。

我会将每个列表字段分成自己的经理。

于 2013-07-29T08:33:22.833 回答
1

关键是您需要禁用Screen包含所有这些管理器和字段的垂直滚动。

然后,您可以创建一个水平字段管理器。然后是三位垂直领域经理。将每个列表放入其自己的垂直字段管理器中,然后所有三个垂直字段管理器都进入水平字段管理器。

这是我测试的一个简单原型:

public class ListFocusScreen extends MainScreen implements ListFieldCallback {

   private ObjectListField list1;
   private ListField list2;
   private ListField list3;
   private Bitmap icon2;   // for list 2 cell background
   private Bitmap icon3;   // for list 3 cell background

   public ListFocusScreen() {
      // Do NOT allow vertical scrolling at the Screen level!!
      super(MainScreen.NO_VERTICAL_SCROLL | MainScreen.NO_VERTICAL_SCROLLBAR);

      // A container for the "row" of three side-by-side lists
      HorizontalFieldManager hfm = new HorizontalFieldManager(Field.USE_ALL_WIDTH);

      // Do create a vertical field manager for each list, that scrolls
      VerticalFieldManager vfm1 = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR) {
         protected void sublayout(int maxWidth, int maxHeight) {
            super.sublayout(2 * Display.getWidth() / 3, maxHeight);   // 2/3 width
         }         
      };
      VerticalFieldManager vfm2 = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR) {
         protected void sublayout(int maxWidth, int maxHeight) {
            super.sublayout(Display.getWidth() / 6, maxHeight);       // 1/6 width
         }         
      };
      VerticalFieldManager vfm3 = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR) {
         protected void sublayout(int maxWidth, int maxHeight) {
            super.sublayout(Display.getWidth() / 6, maxHeight);       // 1/6 width
         }         
      };

      Object[] listData1 = new Object[24];
      for (int i = 0; i < listData1.length; i++) {
         // generate fake data for list1
         listData1[i] = String.valueOf(i) + ". Click to Download";
      }
      list1 = new ObjectListField();
      list1.set(listData1);

      list2 = new ListField();
      list2.setCallback(this);
      icon2 = Bitmap.getBitmapResource("octagon.png");
      list2.setSize(15);

      list3 = new ListField();
      list3.setCallback(this);
      icon3 = Bitmap.getBitmapResource("frame.png");
      list3.setSize(15);

      vfm1.add(list1);
      vfm2.add(list2);
      vfm3.add(list3);
      hfm.add(vfm1);
      hfm.add(vfm2);
      hfm.add(vfm3);
      add(hfm);
   }

   public void drawListRow(ListField listField, Graphics graphics, int index,
         int y, int width) {
      // this same method will be used for custom drawing of both lists 2 and 3
      final int PAD = 4;
      String text = (String)get(listField, index);
      if (listField == list2) {
         graphics.drawBitmap(0, y, width, width, icon2, 0, 0);
         graphics.drawText(text, PAD, y + PAD);
      } else if (listField == list3) {
         graphics.drawBitmap(0, y, width, width, icon3, 0, 0);
         graphics.drawText(text, PAD, y + PAD);
      }      
   }

   public Object get(ListField listField, int index) {
      // TODO: normally, get this value from a vector of actual 
      //  data for each list
      return String.valueOf(index);
   }

   public int getPreferredWidth(ListField listField) {
      return Display.getWidth() / 6;
   }

   public int indexOfList(ListField listField, String prefix, int start) {
      return -1;  // no search support
   }   
}

结果

在此处输入图像描述

如您所见,我能够让每个列表独立地垂直滚动。

于 2013-07-30T09:31:21.123 回答