title: Change button text and action - android development
body: <p>I'm having trouble figuring out how to change the text and action of a button. What I want to do is have a button with the text "play" and when clicked it will play a song and change the text to "pause". then when you click it again, it will pause the song and change the text to "play".</p>
  
  <p>I know how to use the mediaplayer (the coding) and just don't know how to code the button that way:</p>
  
  <p>so far I have:</p>
  
  <pre><code>final Button testButton = (Button) findViewById(R.id.button1);
  testButton.setText("Play");
  testButton.setOnClickListener( new View.OnClickListener() {
  
  @Override
  public void onClick (View v) {
  mPlayer.start();
  testButton.setText("Pause");
  </code></pre>