嗨,我正在做拳击倒计时。我想在所有任务结束后设置文本视图“结束”。但我不知道怎么做。在回合中我看到了(图1)
在休息的时候我看到了(图2)
以及如何使一个条件在所有任务之后看到“end”,因为我使用handler函数重复这个例子2次,当我设置条件时“ if (!tv1.getText().toString().equals("Przerwa"){ tv3.setText("end")
但“结束”告诉我每一次突破。顺便说一句,runda表示rund,这是=tv1 1/2=tv2 2-3-2=tv3 00:03=tv4 tv表示-textview przerwa表示中断
timerododliczania = new CountDownTimer(1000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
btn1.setVisibility(View.INVISIBLE);
tv2.setText("" + millisUntilFinished / 1000);
}
@Override
public void onFinish() {
MediaPlayer boksring=MediaPlayer.create(Main3Activity.this,R.raw.rin9 );
boksring.start();
int liczbarund = 1;
tv4.setText(ilośćrund);
try {
liczbarund = Integer.parseInt(tv4.getText().toString());
} catch (Exception ex) {
Toast.makeText(cntx, "Invalid Integer", Toast.LENGTH_LONG).show();
return;
}
if (liczbarund == 0) {
return;
}
final int[] round_count = {0};
final int finalNum_rounds = liczbarund;
final int[] round_count1 = {0};
final int finalNum_rounds1 = liczbarund;
final int[] round_count2 = {0};
final int finalNum_roundsp = liczbarund;
timerodrundy = new CountDownTimer(dłrundy, 1000) {
@Override
public void onTick(long millisUntilFinished) {
btn1.setVisibility(View.VISIBLE);
tv1.setText("Runda");
tv5.setText( (round_count1[0] + 1) + "/" + finalNum_rounds1);
mTimeLeftInMillis = millisUntilFinished;
updatetext();
}
@Override
public void onFinish() {
tv1.setText("Przerwa");
MediaPlayer r1=MediaPlayer.create(Main3Activity.this, R.raw.rinknkw);
r1.start();
if (licz > 1) {
round_count[0]++;
if (round_count[0] < finalNum_rounds) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
start();
}
}, dłprzerwy);
}
}
if (!tv2.getText().toString().equals("00:00")){
tv3.setText("Koniec");
}
}
}.
start();
timerodkombosa = new CountDownTimer(dłrundy, 5000) {
@Override
public void onTick(long millisUntilFinished) {
final Random rand = ThreadLocalRandom.current();
tv3.setText(kombosy[new Random().nextInt(kombosy.length)]);
int resourceID = R.raw.rin1;
switch (tv3.getText().toString()) {
case "1-2":
resourceID = R.raw.rin1;
break;
case "1-1-2":
resourceID = R.raw.rin2;
break;
case "1-2-3-2":
resourceID = R.raw.rin3;
break;
case "1-2-5-2":
resourceID = R.raw.rin4;
break;
case "1-6-3-2":
resourceID = R.raw.rin5;
break;
case "2-3-2":
resourceID = R.raw.rin6;
break;
}
player = MediaPlayer.create(Main3Activity.this, resourceID);
player.start();
}
@Override
public void onFinish() {
tv5.setText("");
tv3.setText("");
if (licz > 1) {
round_count1[0]++;
if (round_count1[0] < finalNum_rounds1) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
start();
}
}, dłprzerwy);
timerodprzerwy = new CountDownTimer(dłprzerwy, 1000) {
@Override
public void onTick(long millisUntilFinished) {
mTimeLeftInMillis = millisUntilFinished;
updatetext();
}
@Override
public void onFinish() {
MediaPlayer r2=MediaPlayer.create(Main3Activity.this, R.raw.rinnkr);
r2.start();
CountDownTimer countDownTimer= new CountDownTimer(1000,1000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
}
}.start();
暂无答案!
目前还没有任何答案,快来回答吧!