3

こんにちは友人の私の BlackBerry アプリケーションでは、リスト フィールドを使用し、このリスト フィールドにドロップ ダウンを追加します。今私の問題は、リストフィールドに追加したドロップダウンをどのように選択するかです.今、ドロップダウンではなくリストフィールドのみを選択しますが、最初にドロップダウンを選択してからリストフィールドを選択する必要があります. ここにコードを含めましたので、確認してください。

public class TaskListField extends ListField implements ListFieldCallback, KeypadListener {
   private Vector rows;
   private Bitmap p1;
   private Bitmap p2;
   public LoginPage objLoginPage;

   public String[] data={"Call","Visit"};

   public String strIndex = null;
   public int tempIndex = 0;
   public int intvalue;
   public int id;
   public int value;
   public boolean hasFocus = false;
   public static String[] arrOutletName = { "Dosa Store", "Benfish Bhawan",
      "Nalban Park", "Korunamoyee", "206 Bus Stop", "aaaaaaaa",
      "bbbbbbbb", "ccccccccc", "dddddddd", "eeeeeee" };


   public ObjectChoiceField ocf;

   public TaskListField() {
      super(0, ListField.MULTI_SELECT);
      setRowHeight(80);
      setEmptyString("Hooray, no tasks here!", DrawStyle.HCENTER);
      setCallback(this);

      p1 = Bitmap.getBitmapResource("name.png");
      p2 = Bitmap.getBitmapResource("name.png");

      rows = new Vector();

      for (int x = 0; x < XmlHander.vectSrno.size(); x++) {
         TableRowManager row = new TableRowManager();

         strIndex = String.valueOf(x);
         String strVectno = XmlHander.vectSrno.elementAt(x).toString();
         String strSLADate = XmlHander.vectSldate.elementAt(x).toString();

         if (x % 2 == 0) {
            row.add(new BitmapField(null));
         }
         else {
            row.add(new BitmapField(null));
         }


         LabelField task = new LabelField(" ");

         if (x % 15 == 0) {
            task.setFont(Font.getDefault().derive(Font.BOLD | Font.UNDERLINED));
         } else {
            task.setFont(Font.getDefault().derive(Font.BOLD));
         }
         row.add(task);

         row.add(new LabelField(strVectno, DrawStyle.ELLIPSIS) {
            protected void paint(Graphics graphics) {
               graphics.setColor(0x00878787);
               // graphics.setColor(Color.PINK);
               super.paint(graphics);
            }
         });

         row.add(ocf=new ObjectChoiceField("",data){

            protected void paint(Graphics graphics){

               graphics.setColor(0x00878787);
               super.paint(graphics);
            }
         });

         ocf.setChangeListener(new FieldChangeListener(){

            public void fieldChanged(Field field, int context) {
               if(context != PROGRAMMATIC)
                  Dialog.alert(data[ocf.getSelectedIndex()]);
            }
         });

         rows.addElement(row);

      }
      setSize(rows.size());
   }


   public void drawListRow(ListField listField, Graphics g, int index, int y, int width) {
      TaskListField list = (TaskListField) listField;
      TableRowManager rowManager = (TableRowManager) list.rows.elementAt(index);

      rowManager.drawRow(g, 0, y, width, list.getRowHeight());
   }

   private class TableRowManager extends Manager {
      public TableRowManager() {
         super(0);
      }

      public void drawRow(Graphics g, int x, int y, int width, int height) {

         layout(width, height);

         setPosition(x, y);

         g.pushRegion(getExtent());

         subpaint(g);

         g.setColor(0x00CACACA);
         g.drawLine(0, 0, getPreferredWidth(), 0);

         g.popContext();
      }

      protected void sublayout(int width, int height) {

         int fontHeight = Font.getDefault().getHeight();
         int preferredWidth = getPreferredWidth();

         Field field = getField(0);
         layoutChild(field, 32, 32);
         setPositionChild(field, 0, 0);

         field = getField(1);
         layoutChild(field, preferredWidth - 16, fontHeight + 1);
         setPositionChild(field, 34, 3);

         field = getField(2);
         layoutChild(field, 150, fontHeight + 1);
         setPositionChild(field, 34, fontHeight + 6);

         field = getField(3);
         layoutChild(field, 150, fontHeight + 1);
         setPositionChild(field, preferredWidth - 152, fontHeight + 6);

         setExtent(preferredWidth, getPreferredHeight());
      }

      public int getPreferredWidth() {
         return Graphics.getScreenWidth();
      }

      public int getPreferredHeight() {
         return getRowHeight();
      }
   }

   public Object get(ListField listField, int index) {

      return null;
   }

   public int getPreferredWidth(ListField listField) {

      return 0;
   }

   public int indexOfList(ListField listField, String prefix, int start) {

      return 0;
   }

   protected boolean navigationClick(int status, int time) {
      final int index;
      index = this.getFieldWithFocusIndex() - 1;

      UiApplication.getUiApplication().invokeLater(new Runnable() {
         public void run() {

            UiApplication.getUiApplication().pushScreen(new Details(id));
         }
      });

      return false;
   }

   public int moveFocus(int amount, int status, int time) {

      invalidate(getSelectedIndex());
      id = this.getSelectedIndex();
      invalidate();

      return super.moveFocus(amount, status, time);
   }

   public void onFocus(int direction) {

      hasFocus = true;
      super.onFocus(direction);
      System.out.println("direction==" + direction);
      invalidate();
   }

   public void onUnfocus() {

      updateLayout();
      super.onUnfocus();
      invalidate();
   }

   private int getFieldWithFocusIndex() {
      return 0;
   }

}

ここに画像の説明を入力

4

0 に答える 0