示例#1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_go_get_me_gallery_select);

    btnBack = (Button) findViewById(R.id.Back);
    btnBack.setMaxHeight(150);
    btnBack.setMaxWidth(200);
    btnBack.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {

            Intent openEditCat = new Intent(getApplicationContext(), GoGetMeAddLocation.class);
            startActivity(openEditCat);
          }
        });

    btnGallery = (Button) findViewById(R.id.Gallery);
    btnGallery.setMaxHeight(150);
    btnGallery.setMaxWidth(200);

    btnGallery.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {

            Intent openEditCat = new Intent(GoGetMeSelectImage.this, GoGetMeSelectThumb.class);
            startActivity(openEditCat);
          }
        });

    btnSDcard = (Button) findViewById(R.id.Camera);
    btnSDcard.setMaxHeight(150);
    btnSDcard.setMaxWidth(200);
    btnSDcard.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {

            Intent openEditCat = new Intent(GoGetMeSelectImage.this, GoGetMeCameraView.class);
            startActivity(openEditCat);
          }
        });
  }
  private void setStartButton() {
    start = new Button(this);
    start.setText("Start");
    start.setMaxWidth(50);
    start.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            try {
              recordCounter++;
              outputFile =
                  Environment.getExternalStorageDirectory().getAbsolutePath()
                      + "/myrecording"
                      + recordCounter
                      + ".3gp";
              myMediaRecorder = new MediaRecorder();
              myMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
              myMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
              myMediaRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
              myMediaRecorder.setOutputFile(outputFile);

              Toast.makeText(FloatingWindowAudio.this, "Recording started", Toast.LENGTH_SHORT)
                  .show();
              myMediaRecorder.prepare();
              myMediaRecorder.start();

            } catch (Exception e) {
              e.printStackTrace();
            }
            start.setEnabled(false);
            stop.setEnabled(true);
          }
        });
  }
  private void setStopButton() {
    stop = new Button(this);
    stop.setMaxWidth(50);
    stop.setText("Stop");
    stop.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            try {

              Toast.makeText(FloatingWindowAudio.this, "Saved as" + outputFile, Toast.LENGTH_SHORT)
                  .show();
              myMediaRecorder.stop();
              myMediaRecorder.release();

              myMediaRecorder = null;
              stop.setEnabled(false);
              play.setEnabled(true);

            } catch (Exception e) {
              e.printStackTrace();
            }
            start.setEnabled(true);
            play.setEnabled(true);
          }
        });
  }
 private Button createButton(int id, String text) {
   Button btn = new Button(this);
   btn.setId(id);
   btn.setText(text);
   btn.setMinWidth(dp2px(50));
   btn.setMaxWidth(dp2px(120));
   btn.setOnClickListener(this);
   return btn;
 }
示例#5
0
 private void lockButtonSizes(int NUM_ROWS, int NUM_COLS) {
   for (int row = 0; row != NUM_ROWS; row++) {
     for (int col = 0; col != NUM_COLS; col++) {
       Button button = buttons[row][col];
       int width = button.getWidth();
       button.setMinWidth(width);
       button.setMaxWidth(width);
       int height = button.getHeight();
       button.setMinHeight(height);
       button.setMaxHeight(height);
     }
   }
 }
  private void setExitButton() {
    exit = new Button(this);
    exit.setMaxWidth(50);
    exit.setText("Exit");

    exit.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            wm.removeView(ll);
            stopSelf();
          }
        });
  }
  private void setPlayButton() {
    play = new Button(this);
    play.setText("Play");
    play.setMaxWidth(50);
    play.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            try {
              Toast.makeText(FloatingWindowAudio.this, "Playing Audio", Toast.LENGTH_SHORT).show();
              MediaPlayer m = new MediaPlayer();
              m.setDataSource(outputFile);
              m.prepare();
              m.start();

            } catch (Exception e) {
              e.printStackTrace();
            }
            play.setEnabled(true);
            stop.setEnabled(true);
            Toast.makeText(FloatingWindowAudio.this, outputFile, Toast.LENGTH_LONG).show();
          }
        });
  }