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;
 }
  // Method to syncronise in case the toggle is on set the progress of one or the other, if not set
  // the differnce between them
  private void syncronised(SeekBar s, int progress) {
    if (tb.getText().toString().equalsIgnoreCase("ON")) {
      if (s.equals(seekBar1)) seekBar2.setProgress(seekBar1.getProgress());
      else seekBar1.setProgress(seekBar2.getProgress());
      textDifference.setText("" + Math.abs(diff));

    } else {
      textDifference.setText("" + Math.abs(diff));
    }
  }
Пример #3
0
  public void editCrumb(View view) {
    name = crumbName.getText().toString();
    comment = crumbComment.getText().toString();
    tags = crumbTags.getText().toString();
    visibility = toggle.getText().toString();
    Intent intent = new Intent(this, MapsActivity.class);
    Intent intent2 = getIntent();
    id = intent2.getStringExtra(MyCrumbsActivity.CRUMB_ID);

    if (visibility.equals("Private")) isPrivate = true;
    else if (visibility.equals("Public")) isPrivate = false;

    if (name.equals("")) {
      // if user entered nothing then cancel adding a crumb
      setResult(RESULT_CANCELED, intent);
    } else {
      Intent msgIntent = new Intent(this, JSONRequest.class);
      msgIntent.putExtra(JSONRequest.IN_MSG, "editCrumb");
      msgIntent.putExtra("queryID", "editCrumb");

      msgIntent.putExtra(
          "jsonObject",
          "{\"username\":\""
              + GlobalContainer.user.getInfo()[0]
              + "\",\"email\":\""
              + GlobalContainer.user.getInfo()[1]
              + "\",\"crumbID\":\""
              + id
              + "\",\"crumbName\":\""
              + name
              + "\",\"isPrivate\":\""
              + isPrivate
              + "\",\"comment\":\""
              + comment
              + "\",\"tags\":\""
              + tags
              + "\"}");
      msgIntent.putExtra("intent", intent.toUri(Intent.URI_INTENT_SCHEME));
      startService(msgIntent);

      // place into intent to pass back to MapsActivity
      intent.putExtra(MapsActivity.NAME, name);
      intent.putExtra(MapsActivity.COMMENT, comment);
      setResult(RESULT_OK, intent); // send result code
    }
  }
Пример #4
0
        @Override
        public void onClick(View v) {
          Button btnButton = (Button) v;

          switch (btnButton.getId()) {
            case R.id.Button1:
              Toast.makeText(MainActivity.this, "按钮1单机", Toast.LENGTH_LONG).show();
              break;
            case R.id.Button2:
              Toast.makeText(MainActivity.this, "按钮2单机", Toast.LENGTH_LONG).show();
              break;

            default:
              ToggleButton tgb = (ToggleButton) v;
              Toast.makeText(MainActivity.this, tgb.getText(), Toast.LENGTH_LONG).show();
              break;
          }
        }