Reputation: 577
I'm having issues with my app. I'm writing a method with a CountDownTimer and I'm passing an argument 'velocidadbpm' which is a variable with an integer. When I compile I have the following error error: method reproducirSonidoCountDownTimer in class metronomo cannot be applied to given types; required: int found: no arguments reason: actual and formal argument lists differ in length
This is the method public class metronomo extends AppCompatActivity {
private TextView numerobpm;
private TextView bpm;
private TextView variablevelocidadbpm;
private TextView nombreitaliano;
private RadioButton metronomoizq;
private RadioButton metronomoder;
private static SeekBar seekbarmetronomo;
private Button play;
private int velocidadbpm;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_metronomo);
variablevelocidadbpm = (TextView)findViewById(R.id.variablevelocidadbpm);
nombreitaliano = (TextView)findViewById(R.id.nombreitaliano);
numerobpm = (TextView) findViewById(R.id.numerobpm);
bpm = (TextView) findViewById(R.id.bpm);
metronomoizq = (RadioButton) findViewById(R.id.metronomoizq);
metronomoder = (RadioButton) findViewById(R.id.metronomoder);
play = (Button)findViewById(R.id.playbutton);
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
reproducirSonidoCountDownTimer();
}
});
seekbarmetronomo = (SeekBar) findViewById(R.id.seekbarmetronomo);
seekbarmetronomo.setProgress(0);
seekbarmetronomo.incrementProgressBy(25);
seekbarmetronomo.setMax(250);
//Indica en el TextView nombreitaliano El ritmo del metrónomo.
seekbarmetronomo.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
progress = progress / 1;
progress = progress * 1;
velocidadbpm = progress;
//Cambia el número de BPM en el TextView numerobpm
numerobpm.setText(Integer.toString(progress));
//Guarda en la variable velocidad bpm el número de BPM para ser utilizado como parámetro
variablevelocidadbpm.setText(Integer.toString(velocidadbpm));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
public void reproducirSonidoCountDownTimer(int velocidadbpm) {
this.velocidadbpm = velocidadbpm;
int intervalo = velocidadbpm * 60000;
new CountDownTimer(60000, intervalo) {
public void onTick(long millisUntilFinished){
reproducirSonido();
}
public void onFinish(){
}
}.start();
}
Upvotes: 0
Views: 1138
Reputation: 15423
You have to pass int
value to call reproducirSonidoCountDownTimer
. Problem is in your onClick
, update this.
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
reproducirSonidoCountDownTimer();
}
});
Invoke the function with some value. In Android Studio you see a red mark besides this line. I don't know, how could you miss that?
Upvotes: 1
Reputation: 343
You are calling the function with no arguments. Here
reproducirSonidoCountDownTimer(**Pass an int here**);
While your function needs an argument.
public void reproducirSonidoCountDownTimer(int velocidadbpm)
Upvotes: 0