Esempio n. 1
0
    void populateFrom(final int position) {
      final Profile account = getItem(position);
      Protocol p = RosterHelper.getInstance().getProtocol(account);
      if (null != p) {
        ImageView icProtocol = getImageProtocol();
        Icon ic = p.getStatusInfo().getIcon((byte) 0);
        if (ic != null) {
          icProtocol.setVisibility(ImageView.VISIBLE);
          icProtocol.setImageDrawable(ic.getImage());
        } else {
          icProtocol.setVisibility(ImageView.GONE);
        }
      }
      getTextLogin().setText(account.userId);
      ToggleButton tb = getToggleButton();
      tb.setChecked(account.isActive);
      tb.setFocusableInTouchMode(false);
      tb.setFocusable(false);

      tb.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              ToggleButton t = (ToggleButton) v.findViewById(R.id.toggle_button);
              account.isActive = t.isChecked();
              RosterHelper.getInstance().setCurrentProtocol();
              Options.saveAccount(account);
              notifyDataSetChanged();
            }
          });
    }
 private ToggleButton initToggleButton(View view, int id) {
   ToggleButton ret = (ToggleButton) view.findViewById(id);
   ret.setFocusable(false);
   ret.setEnabled(false);
   CharSequence str = ret.getText();
   ret.setTextOff(str);
   ret.setTextOn(str);
   return ret;
 }
Esempio n. 3
0
  public UISwitcher() {
    ToggleButton btn = new ToggleButton(context);
    btn.setTextColor(Color.TRANSPARENT);
    btn.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            UISwitcher.this.setOn(isChecked, YES);
          }
        });
    this.setSwitcher(btn);
    btn.setFocusable(NO);
    this.setView(btn);
    this.setFrame(CGRectMake(0, 0, 0, 0));

    onImage = new UIImage(R.drawable.zz_c4a_switcher_on);
    offImage = new UIImage(R.drawable.zz_c4a_switcher_off);
    this.setOn(YES, YES);
  }