黑莓:获取复选框字段数据

时间:2011-11-15 08:53:06

标签: blackberry

我已经成功制作了列表视图,其中包含带有复选框的联系人列表。现在问题是我必须获取复选框字段数据但是null即将到来。你能告诉我我在哪里做错了吗?代码段是: 更新:我得到了更新代码在

之下的字段数据
 private Vector _listData = new Vector();
    private ListField listField;
        private ContactList blackBerryContactList;
    private Vector blackBerryContacts;
    public static StringBuffer sbi = new StringBuffer();
        VerticalFieldManager checkBoxGroup = new VerticalFieldManager();
    CheckboxField cb;

    //Constructor
    CheckboxListField() {  
    listField = new ListField();
            listField.setCallback(this);
            reloadContactList();
    for(int count = 0; count < blackBerryContacts.size(); ++count)
            {
                BlackBerryContact item =
                    (BlackBerryContact)blackBerryContacts.elementAt(count);
                    String displayName = getDisplayName(item);
                    CheckboxField cb = new CheckboxField(displayName, false);
                    cb.setChangeListener(this);
                    add(cb);
                    add(new RichTextField(cb.getLabel()));
    }
            add(new RichTextField(checkBoxGroup.toString()));
            blackBerryContacts.addElement(cb);
            add(checkBoxGroup);
    }

    public void fieldChanged(Field field, int context) {
          boolean mProgrammatic = false;

          if (!mProgrammatic) {
          mProgrammatic = true;
          cbField = (CheckboxField) field;
          int index = blackBerryContacts.indexOf(cbField);

          if (cbField.getChecked())
          {
             for(int i=0;i<blackBerryContacts.size();i++)
             {
             Dialog.inform("Selected::" + cbField.getLabel());
             sbi=new StringBuffer();
             sbi.append(cbField.getLabel());

             }                 
          }

          mProgrammatic = false;
      }

      }}

0 个答案:

没有答案