1
I’m creating an app, in JAVA, that plays songs by pressing a certain button. But when you press the button again, the music is repeated. And I would like to stop it by touching the same button.
package dagustin.southamericamemes;
import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onClickTocar(View view){
MediaPlayer mp = MediaPlayer.create(this , R.raw.morre);
mp.start();
}
}
Murilo, could you put an excerpt from the code?
– William Pereira
Opa clear I’ll catch him here.
– Murilo Dagustin
Oops, buddy I’m new to Stackoverflow like I do to glue it like a code?
– Murilo Dagustin
Murilo, click edit on the question you asked, then paste the code.
– William Pereira
It keeps getting like a normal text
– Murilo Dagustin
To add formatting you must put in your question, comments cannot insert specific formatting click edit your answer, and in the field with {} select your code and click this button. the code will indent itself automatically remember to put spaces and the like, since the indentation does not put paragraphs, just hits the patterns
– Daniel Gentil
Okay, thanks I’ll try
– Murilo Dagustin
Whoa, William, I just got the code down below.
– Murilo Dagustin
If you have any doubts about how to do it correctly follow the tour of the site http://answall.com/tour
– Daniel Gentil
Thank you, I had already seen an answer in that "forum" but had not understood the answer.
– Murilo Dagustin