public void clearFields(View v) {

    editFromDate.setText("");
    editToDate.setText("");
    editFromAmount.setTag("");
    editToAmount.setTag("");
  }
示例#2
0
  /**
   * 初始化Spinner
   *
   * @param rootGroup
   * @param spinnerId
   */
  public Spinner InitSpinner(
      View rootGroup, int spinnerId, String[] arrStringDatas, String[] arrValues, String defValue) {
    Spinner spinner = (Spinner) rootGroup.findViewById(spinnerId);
    spinner.setTag(arrValues);
    // 设置风格
    BaseAdapter adapter = new MSpinnerAdatpter(spinner, getActivity(), arrStringDatas);
    spinner.setAdapter(adapter);

    // 设置默认值
    if (defValue != null && !defValue.equalsIgnoreCase("")) {
      if (arrStringDatas != null && arrStringDatas.length > 0) {
        // int i = 0;
        int index = 0;
        for (int i = 0; i < arrStringDatas.length; i++) {
          if (arrStringDatas[i] != null
              && (arrStringDatas[i].equalsIgnoreCase(defValue)
                  || arrValues[i].equalsIgnoreCase(defValue))) {
            index = i;
            break;
          }
          // i++;
        }
        spinner.setSelection(index, true);
      }
    }
    return spinner;
  }
示例#3
0
 public FormBuilder addSpinner(String fieldName, String tag, SpinnerAdapter da) {
   TextView tv = new TextView(context);
   tv.setTextColor(theme.getTextColor());
   tv.setLayoutParams(new LayoutParams(theme.getLabelWidth(), theme.getLabelHeight()));
   ll.addView(tv);
   Spinner s = new Spinner(context);
   s.setTag(tag);
   s.setLayoutParams(new LayoutParams(theme.getLabelWidth(), theme.getLabelHeight()));
   s.setAdapter(da);
   ll.addView(s);
   return this;
 }
示例#4
0
  private void populate() {
    typePokemonCrud = new TypePokemonCrud(this);
    List<TypeEntity> data = typePokemonCrud.all();

    spType1.setAdapter(new TypeAdapter(this, data));
    spType1.setTag(true);

    spType2.setAdapter(new TypeAdapter(this, data));
    spType2.setTag(true);

    spType1.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
            boolean tag = (boolean) spType1.getTag();
            if (tag) {
              tag = false;
              spType1.setTag(tag);
            } else {
              if (position > 0) {
                Log.v(TAG, "onItemSelected " + position);
                TypeEntity typeEntity = (TypeEntity) adapterView.getAdapter().getItem(position);
                eTxtType1.setText(typeEntity.getName());
                type1 = typeEntity.getType_id();
              } else {
                type1 = -1;
              }
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {
            Log.v(TAG, "onNothingSelected");
          }
        });

    spType2.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
            boolean tag = (boolean) spType2.getTag();
            if (tag) {
              tag = false;
              spType2.setTag(tag);
            } else {
              if (position > 0) {
                Log.v(TAG, "onItemSelected " + position);
                TypeEntity typeEntity = (TypeEntity) adapterView.getAdapter().getItem(position);
                eTxtType2.setText(typeEntity.getName());
                type2 = typeEntity.getType_id();
              } else {
                type2 = -1;
              }
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {
            Log.v(TAG, "onNothingSelected");
          }
        });
  }