- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在单击按钮时取消 countdountimer 的 onfinish 函数我执行 timer.cancel 但仍然调用 on finish。
running = false;
countDownTimer.cancel();
countDownTimer = null;
finish();
startActivity(i);
这是倒计时
private CountDownTimer createTimer() {
return new CountDownTimer(getIntent().getIntExtra("timer", 5460000),
1000) {
@SuppressLint("NewApi")
public void onTick(long millisUntilFinished) {
timer.setText("Section time: "
+ String.format(
Locale.ENGLISH,
"%d min, %d sec",
TimeUnit.MILLISECONDS
.toMinutes(millisUntilFinished),
TimeUnit.MILLISECONDS
.toSeconds(millisUntilFinished)
- TimeUnit.MINUTES
.toSeconds(TimeUnit.MILLISECONDS
.toMinutes(millisUntilFinished))));
timer_count = (int) millisUntilFinished;
}
public void onFinish() {
if (running) {
int random;
if (getIntent().getIntExtra("t_no", 0) < 20) {
i = new Intent(getApplicationContext(),
Practice_intruction.class);
i.putExtra("type", "Test");
Random r = new Random();
random = r.nextInt(MainActivity.vocab.size() - 11);
i.putExtra("q_no", random);
i.putExtra("t_no", 20);
i.putExtra("answers",
getIntent().getStringExtra("answers"));
countDownTimer.cancel();
countDownTimer = null;
running = false;
finish();
startActivity(i);
} else if (getIntent().getIntExtra("t_no", 0) < 40) {
i = new Intent(getApplicationContext(),
Practice_intruction.class);
i.putExtra("type", "Test");
Random r = new Random();
random = r.nextInt(MainActivity.listining.size() - 4);
i.putExtra("q_no", random);
i.putExtra("t_no", 40);
i.putExtra("answers",
getIntent().getStringExtra("answers"));
countDownTimer.cancel();
countDownTimer = null;
running = false;
finish();
startActivity(i);
} else if (getIntent().getIntExtra("t_no", 0) < 50) {
i = new Intent(getApplicationContext(),
Practice_intruction.class);
i.putExtra("type", "Test");
Random r = new Random();
random = r.nextInt(MainActivity.reading.size() - 1);
i.putExtra("paragraph_id", random + 1);
i.putExtra("q_no", 0);
i.putExtra("t_no", 50);
i.putExtra("answers",
getIntent().getStringExtra("answers"));
countDownTimer.cancel();
countDownTimer = null;
running = false;
finish();
startActivity(i);
} else if (getIntent().getIntExtra("t_no", 0) < 60) {
i = new Intent(getApplicationContext(),
Practice_intruction.class);
i.putExtra("type", "Test");
Random r = new Random();
random = r.nextInt(MainActivity.vid.size() - 1);
i.putExtra("Scene_ID", random + 1);
i.putExtra("q_no", 0);
i.putExtra("t_no", 60);
i.putExtra("answers",
getIntent().getStringExtra("answers"));
countDownTimer.cancel();
countDownTimer = null;
running = false;
finish();
startActivity(i);
} else if (getIntent().getIntExtra("t_no", 0) < 100) {
i = new Intent(getApplicationContext(),
Practice_result.class);
i.putExtra("type", getIntent().getStringExtra("type"));
i.putExtra("answers",
getIntent().getStringExtra("answers"));
countDownTimer.cancel();
countDownTimer = null;
running = false;
finish();
startActivity(i);
}
}
}
}.start();
}
这是我使用倒数计时器的 Activity 的一部分,除了这里我没有在任何地方使用它
else if (getIntent().getStringExtra("type").equalsIgnoreCase("Test")) {
timer.setVisibility(View.VISIBLE);
back.setVisibility(View.INVISIBLE);
running = true;
countDownTimer = this.createTimer();
if (getIntent().getIntExtra("t_no", 0) < 10) {
final ArrayList<HashMap<String, String>> questions = new ArrayList<HashMap<String, String>>();
for (int i = 0; i < 50; i++) {
if (MainActivity.structure.get(i).get("type_p_t")
.equalsIgnoreCase("t"))
questions.add(MainActivity.structure.get(i));
}
main_txt.setText("Q"
+ (getIntent().getIntExtra("t_no", 0) + 1)
+ ": "
+ questions.get(getIntent().getIntExtra("q_no", 0))
.get("question").replace("#", ""));
title.setText("Structure/ Sentence Completion");
opt_a_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[0]);
opt_b_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[1]);
opt_c_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[2]);
opt_d_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[3]);
cor_ans = questions.get(getIntent().getIntExtra("q_no", 0))
.get("cor_ans");
next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int random;
if (getIntent().getIntExtra("t_no", 0) == 9) {
i = new Intent(getApplicationContext(),
Practice_intruction.class);
i.putExtra("type", "Test");
Random r = new Random();
random = r.nextInt(MainActivity.structure.size() - 51);
} else {
i = new Intent(getApplicationContext(),
Struct.class);
i.putExtra("type",
getIntent().getStringExtra("type"));
Random r = new Random();
random = r.nextInt(MainActivity.structure.size() - 51);
while (Helper.sec_questions.contains(random)) {
random = r.nextInt(MainActivity.structure
.size() - 51);
}
Helper.sec_questions.add(random);
}
i.putExtra("q_no", random);
i.putExtra("t_no",
getIntent().getIntExtra("t_no", 0) + 1);
if (ans.equalsIgnoreCase(cor_ans)) {
i.putExtra("answers",
getIntent().getStringExtra("answers")
+ "true#");
} else {
i.putExtra("answers",
getIntent().getStringExtra("answers")
+ "false#");
}
i.putExtra("timer", timer_count);
Details_data.answers.add(ans);
Details_data.choices.add(opt_a_txt.getText().toString()
+ "#" + opt_b_txt.getText().toString() + "#"
+ opt_c_txt.getText().toString() + "#"
+ opt_d_txt.getText().toString());
Details_data.correct_answers.add(cor_ans);
Details_data.questions.add(main_txt.getText()
.toString());
Details_data.why.add(questions
.get(getIntent().getIntExtra("q_no", 0))
.get("why").replace("#", ""));
running = false;
countDownTimer.cancel();
countDownTimer.onFinish();
countDownTimer = null;
finish();
startActivity(i);
}
});
} else if (getIntent().getIntExtra("t_no", 0) < 20) {
final ArrayList<HashMap<String, String>> questions = new ArrayList<HashMap<String, String>>();
for (int i = 50; i < MainActivity.structure.size(); i++) {
if (MainActivity.structure.get(i).get("type_p_t")
.equalsIgnoreCase("t"))
questions.add(MainActivity.structure.get(i));
}
main_txt.setText("Q"
+ (getIntent().getIntExtra("t_no", 0) + 1)
+ ": "
+ questions.get(getIntent().getIntExtra("q_no", 0))
.get("question").replace("#", ""));
title.setText("Structure/ Error Identification");
opt_a_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[0]);
opt_b_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[1]);
opt_c_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[2]);
opt_d_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[3]);
cor_ans = questions.get(getIntent().getIntExtra("q_no", 0))
.get("cor_ans");
next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int random;
if (getIntent().getIntExtra("t_no", 0) == 19) {
i = new Intent(getApplicationContext(),
Practice_intruction.class);
i.putExtra("type", "Test");
Random r = new Random();
random = r.nextInt(MainActivity.vocab.size() - 11);
} else {
i = new Intent(getApplicationContext(),
Struct.class);
i.putExtra("type",
getIntent().getStringExtra("type"));
Random r = new Random();
random = r.nextInt(MainActivity.structure.size() - 51);
while (Helper.sec_questions.contains(random)) {
random = r.nextInt(MainActivity.structure
.size() - 51);
}
Helper.sec_questions.add(random);
}
i.putExtra("q_no", random);
i.putExtra("t_no",
getIntent().getIntExtra("t_no", 0) + 1);
if (ans.equalsIgnoreCase(cor_ans)) {
i.putExtra("answers",
getIntent().getStringExtra("answers")
+ "true#");
} else {
i.putExtra("answers",
getIntent().getStringExtra("answers")
+ "false#");
}
i.putExtra("timer", timer_count);
Details_data.answers.add(ans);
Details_data.choices.add(opt_a_txt.getText().toString()
+ "#" + opt_b_txt.getText().toString() + "#"
+ opt_c_txt.getText().toString() + "#"
+ opt_d_txt.getText().toString());
Details_data.correct_answers.add(cor_ans);
Details_data.questions.add(main_txt.getText()
.toString());
Details_data.why.add(questions
.get(getIntent().getIntExtra("q_no", 0))
.get("why").replace("#", ""));
running = false;
countDownTimer.cancel();
countDownTimer.onFinish();
countDownTimer = null;
finish();
startActivity(i);
}
});
} else if (getIntent().getIntExtra("t_no", 0) < 40) {
final ArrayList<HashMap<String, String>> questions = new ArrayList<HashMap<String, String>>();
for (int i = 0; i < MainActivity.vocab.size(); i++) {
if (MainActivity.vocab.get(i).get("type_p_t")
.equalsIgnoreCase("t"))
questions.add(MainActivity.vocab.get(i));
}
main_txt.setText("Q"
+ (getIntent().getIntExtra("t_no", 0) + 1)
+ ": "
+ questions.get(getIntent().getIntExtra("q_no", 0))
.get("question").replace("#", ""));
title.setText("Vocabulary");
opt_a_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[0]);
opt_b_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[1]);
opt_c_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[2]);
opt_d_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[3]);
cor_ans = questions.get(getIntent().getIntExtra("q_no", 0))
.get("cor_ans");
next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int random;
if (getIntent().getIntExtra("t_no", 0) == 39) {
i = new Intent(getApplicationContext(),
Practice_intruction.class);
i.putExtra("type", "Test");
Random r = new Random();
random = r.nextInt(MainActivity.listining.size() - 4);
} else {
i = new Intent(getApplicationContext(),
Struct.class);
i.putExtra("type",
getIntent().getStringExtra("type"));
Random r = new Random();
random = r.nextInt(MainActivity.vocab.size() - 11);
while (Helper.sec_questions.contains(random)) {
random = r.nextInt(MainActivity.vocab.size() - 11);
}
Helper.sec_questions.add(random);
}
i.putExtra("q_no", random);
i.putExtra("t_no",
getIntent().getIntExtra("t_no", 0) + 1);
if (ans.equalsIgnoreCase(cor_ans)) {
i.putExtra("answers",
getIntent().getStringExtra("answers")
+ "true#");
} else {
i.putExtra("answers",
getIntent().getStringExtra("answers")
+ "false#");
}
i.putExtra("timer", timer_count);
Details_data.answers.add(ans);
Details_data.choices.add(opt_a_txt.getText().toString()
+ "#" + opt_b_txt.getText().toString() + "#"
+ opt_c_txt.getText().toString() + "#"
+ opt_d_txt.getText().toString());
Details_data.correct_answers.add(cor_ans);
Details_data.questions.add(main_txt.getText()
.toString());
running = false;
countDownTimer.cancel();
countDownTimer.onFinish();
countDownTimer = null;
finish();
startActivity(i);
}
});
} else if (getIntent().getIntExtra("t_no", 0) < 50) {
final ArrayList<HashMap<String, String>> questions = new ArrayList<HashMap<String, String>>();
main_txt.setVisibility(View.GONE);
opt_a.setVisibility(View.GONE);
opt_b.setVisibility(View.GONE);
opt_c.setVisibility(View.GONE);
opt_d.setVisibility(View.GONE);
headset.setVisibility(View.VISIBLE);
for (int i = 0; i < MainActivity.listining.size(); i++) {
if (MainActivity.listining.get(i).get("type_p_t")
.equalsIgnoreCase("t"))
questions.add(MainActivity.listining.get(i));
}
main_txt.setText("Q"
+ (getIntent().getIntExtra("t_no", 0) + 1)
+ ": "
+ questions.get(getIntent().getIntExtra("q_no", 0))
.get("question").replace("#", ""));
title.setText("Listening Comprehension");
opt_a_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[0]);
opt_b_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[1]);
opt_c_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[2]);
opt_d_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[3]);
cor_ans = questions.get(getIntent().getIntExtra("q_no", 0))
.get("cor_ans");
next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int random;
if (getIntent().getIntExtra("t_no", 0) == 49) {
i = new Intent(getApplicationContext(),
Practice_intruction.class);
i.putExtra("type",
getIntent().getStringExtra("type"));
Random r = new Random();
random = r.nextInt(MainActivity.reading.size() - 1);
i.putExtra("paragraph_id", random + 1);
i.putExtra("q_no", 0);
} else {
i = new Intent(getApplicationContext(),
Struct.class);
i.putExtra("type",
getIntent().getStringExtra("type"));
Random r = new Random();
random = r.nextInt(MainActivity.listining.size() - 4);
while (Helper.sec_questions.contains(random)) {
random = r.nextInt(MainActivity.listining
.size() - 4);
}
Helper.sec_questions.add(random);
i.putExtra("q_no", random);
}
i.putExtra("t_no",
getIntent().getIntExtra("t_no", 0) + 1);
if (ans.equalsIgnoreCase(cor_ans)) {
i.putExtra("answers",
getIntent().getStringExtra("answers")
+ "true#");
} else {
i.putExtra("answers",
getIntent().getStringExtra("answers")
+ "false#");
}
i.putExtra("timer", timer_count);
Details_data.answers.add(ans);
Details_data.choices.add(opt_a_txt.getText().toString()
+ "#" + opt_b_txt.getText().toString() + "#"
+ opt_c_txt.getText().toString() + "#"
+ opt_d_txt.getText().toString());
Details_data.correct_answers.add(cor_ans);
Details_data.questions.add(main_txt.getText()
.toString());
running = false;
countDownTimer.cancel();
countDownTimer.onFinish();
countDownTimer = null;
finish();
startActivity(i);
}
});
listen.setVisibility(View.VISIBLE);
mp = new MediaPlayer();
listen.setOnClickListener(new OnClickListener() {
@SuppressLint("SdCardPath")
@Override
public void onClick(View v) {
try {
mp.setDataSource("/mnt/sdcard/qualification/"
+ questions.get(
getIntent().getIntExtra("q_no", 0))
.get("voice") + ".mp3");
mp.prepare();
mp.start();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
listen.setVisibility(View.GONE);
}
});
mp.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
mp.release();
mp = null;
main_txt.setVisibility(View.VISIBLE);
opt_a.setVisibility(View.VISIBLE);
opt_b.setVisibility(View.VISIBLE);
opt_c.setVisibility(View.VISIBLE);
opt_d.setVisibility(View.VISIBLE);
headset.setVisibility(View.GONE);
}
});
} else if (getIntent().getIntExtra("t_no", 0) < 60) {
paragraph.setVisibility(View.VISIBLE);
final ArrayList<HashMap<String, String>> questions = new ArrayList<HashMap<String, String>>();
for (int i = 0; i < MainActivity.reading_qst.size(); i++) {
if (MainActivity.reading_qst
.get(i)
.get("paragraph_id")
.equalsIgnoreCase(
String.valueOf(getIntent().getIntExtra(
"paragraph_id", 0) + 1)))
questions.add(MainActivity.reading_qst.get(i));
}
main_txt.setText("Q"
+ (getIntent().getIntExtra("t_no", 0) + 1)
+ ": "
+ questions.get(getIntent().getIntExtra("q_no", 0))
.get("question").replace("#", ""));
title.setText("Reading Comprehension");
opt_a_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[0]);
opt_b_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[1]);
opt_c_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[2]);
opt_d_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[3]);
cor_ans = questions.get(getIntent().getIntExtra("q_no", 0))
.get("cor_ans");
next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int random;
if (getIntent().getIntExtra("t_no", 0) == 59) {
i = new Intent(getApplicationContext(),
Practice_intruction.class);
i.putExtra("type", "Test");
Random r = new Random();
random = r.nextInt(MainActivity.vid.size() - 1);
i.putExtra("Scene_ID", random + 1);
i.putExtra("q_no", 0);
} else if (getIntent().getIntExtra("t_no", 0) == 54) {
i = new Intent(getApplicationContext(),
Reading.class);
i.putExtra("type", "Test");
Random r = new Random();
random = r.nextInt(MainActivity.reading.size() - 1);
while (Helper.sec_questions.contains(random)) {
random = r.nextInt(MainActivity.reading.size() - 2);
}
Helper.sec_questions.add(random + 1);
i.putExtra("paragraph_id", random + 1);
i.putExtra("q_no", 0);
} else {
i = new Intent(getApplicationContext(),
Struct.class);
i.putExtra("type",
getIntent().getStringExtra("type"));
i.putExtra("paragraph_id",
getIntent().getIntExtra("paragraph_id", 0));
i.putExtra("q_no",
getIntent().getIntExtra("q_no", 0) + 1);
}
i.putExtra("t_no",
getIntent().getIntExtra("t_no", 0) + 1);
if (ans.equalsIgnoreCase(cor_ans)) {
i.putExtra("answers",
getIntent().getStringExtra("answers")
+ "true#");
} else {
i.putExtra("answers",
getIntent().getStringExtra("answers")
+ "false#");
}
i.putExtra("timer", timer_count);
Details_data.answers.add(ans);
Details_data.choices.add(opt_a_txt.getText().toString()
+ "#" + opt_b_txt.getText().toString() + "#"
+ opt_c_txt.getText().toString() + "#"
+ opt_d_txt.getText().toString());
Details_data.correct_answers.add(cor_ans);
Details_data.questions.add(main_txt.getText()
.toString());
running = false;
countDownTimer.cancel();
countDownTimer.onFinish();
countDownTimer = null;
finish();
startActivity(i);
}
});
}
else if (getIntent().getIntExtra("t_no", 0) < 100) {
final ArrayList<HashMap<String, String>> questions = new ArrayList<HashMap<String, String>>();
for (int i = 0; i < MainActivity.vid_qst.size(); i++) {
if (MainActivity.vid_qst
.get(i)
.get("Scene_ID")
.equalsIgnoreCase(
String.valueOf(getIntent().getIntExtra(
"Scene_ID", 0) + 1)))
questions.add(MainActivity.vid_qst.get(i));
}
main_txt.setText("Q"
+ (getIntent().getIntExtra("t_no", 0) + 1)
+ ": "
+ questions.get(getIntent().getIntExtra("q_no", 0))
.get("question").replace("#", ""));
title.setText("Visual Comprehension");
opt_a_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[0]);
opt_b_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[1]);
opt_c_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[2]);
opt_d_txt.setText(questions
.get(getIntent().getIntExtra("q_no", 0)).get("choices")
.split("#")[3]);
cor_ans = questions.get(getIntent().getIntExtra("q_no", 0))
.get("cor_ans");
next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (getIntent().getIntExtra("t_no", 0) == 99) {
i = new Intent(getApplicationContext(),
Practice_result.class);
i.putExtra("type",
getIntent().getStringExtra("type"));
} else if (getIntent().getIntExtra("t_no", 0) == 59
|| getIntent().getIntExtra("t_no", 0) == 69
|| getIntent().getIntExtra("t_no", 0) == 79
|| getIntent().getIntExtra("t_no", 0) == 89) {
i = new Intent(getApplicationContext(), Video.class);
i.putExtra("type", "Test");
Random r = new Random();
int random = r.nextInt(MainActivity.vid.size() - 1);
while (Helper.sec_questions.contains(random)) {
random = r.nextInt(MainActivity.vid.size() - 1);
}
Helper.sec_questions.add(random + 1);
i.putExtra("Scene_ID", random + 1);
i.putExtra("q_no", 0);
} else {
i = new Intent(getApplicationContext(),
Struct.class);
i.putExtra("type",
getIntent().getStringExtra("type"));
i.putExtra("q_no",
getIntent().getIntExtra("q_no", 0) + 1);
i.putExtra("Scene_ID",
getIntent().getIntExtra("Scene_ID", 0));
}
i.putExtra("t_no",
getIntent().getIntExtra("t_no", 0) + 1);
if (ans.equalsIgnoreCase(cor_ans)) {
i.putExtra("answers",
getIntent().getStringExtra("answers")
+ "true#");
} else {
i.putExtra("answers",
getIntent().getStringExtra("answers")
+ "false#");
}
i.putExtra("timer", timer_count);
Details_data.answers.add(ans);
Details_data.choices.add(opt_a_txt.getText().toString()
+ "#" + opt_b_txt.getText().toString() + "#"
+ opt_c_txt.getText().toString() + "#"
+ opt_d_txt.getText().toString());
Details_data.correct_answers.add(cor_ans);
Details_data.questions.add(main_txt.getText()
.toString());
running = false;
countDownTimer.cancel();
countDownTimer.onFinish();
countDownTimer = null;
finish();
startActivity(i);
}
});
}
}
opt_a.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
opt_a_img.setImageResource(R.drawable.ans_sel_yallow);
opt_b_img.setImageResource(R.drawable.ans_sel_white);
opt_c_img.setImageResource(R.drawable.ans_sel_white);
opt_d_img.setImageResource(R.drawable.ans_sel_white);
ans = "a";
next.setVisibility(View.VISIBLE);
paragraph.setVisibility(View.GONE);
}
});
opt_b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
opt_a_img.setImageResource(R.drawable.ans_sel_white);
opt_b_img.setImageResource(R.drawable.ans_sel_yallow);
opt_c_img.setImageResource(R.drawable.ans_sel_white);
opt_d_img.setImageResource(R.drawable.ans_sel_white);
ans = "b";
next.setVisibility(View.VISIBLE);
paragraph.setVisibility(View.GONE);
}
});
opt_c.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
opt_a_img.setImageResource(R.drawable.ans_sel_white);
opt_b_img.setImageResource(R.drawable.ans_sel_white);
opt_c_img.setImageResource(R.drawable.ans_sel_yallow);
opt_d_img.setImageResource(R.drawable.ans_sel_white);
ans = "c";
next.setVisibility(View.VISIBLE);
paragraph.setVisibility(View.GONE);
}
});
opt_d.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
opt_a_img.setImageResource(R.drawable.ans_sel_white);
opt_b_img.setImageResource(R.drawable.ans_sel_white);
opt_c_img.setImageResource(R.drawable.ans_sel_white);
opt_d_img.setImageResource(R.drawable.ans_sel_yallow);
ans = "d";
next.setVisibility(View.VISIBLE);
paragraph.setVisibility(View.GONE);
}
});
back.setOnClickListener(new OnClickListener() {
@SuppressWarnings("deprecation")
@Override
public void onClick(View v) {
AlertDialog alert = new AlertDialog.Builder(Struct.this)
.create();
if (alert != null) {
alert.setMessage("Are you sure you want to exit?!");
alert.setCancelable(true);
alert.setButton("Yes",
new DialogInterface.OnClickListener() {
@SuppressLint("NewApi")
public void onClick(DialogInterface dialog,
int id) {
Intent i = new Intent(
getApplicationContext(),
MainMenu.class);
running = false;
if (countDownTimer != null) {
countDownTimer.cancel();
countDownTimer.onFinish();
countDownTimer = null;
}
finish();
startActivity(i);
}
});
alert.setButton2("No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
}
});
alert.setCanceledOnTouchOutside(false);
alert.show();
TextView msg = (TextView) alert
.findViewById(android.R.id.message);
if (msg != null)
msg.setTextSize(20);
Button b1 = (Button) alert
.findViewById(android.R.id.button1);
if (b1 != null)
b1.setTextSize(20);
Button b2 = (Button) alert
.findViewById(android.R.id.button2);
if (b2 != null)
b2.setTextSize(20);
}
}
});
paragraph.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
i = new Intent(getApplicationContext(), Reading.class);
i.putExtra("type", getIntent().getStringExtra("type"));
i.putExtra("paragraph_id",
getIntent().getIntExtra("paragraph_id", 0));
i.putExtra("q_no", getIntent().getIntExtra("q_no", 0));
i.putExtra("t_no", getIntent().getIntExtra("t_no", 0));
i.putExtra("answers", getIntent().getStringExtra("answers"));
i.putExtra("timer", timer_count);
i.putExtra("return", true);
startActivity(i);
}
});
}
最佳答案
似乎在任何情况下都会调用 finish()。但是,如果您在取消之前将 running 设置为 false,则您的 finish() 方法不会执行任何操作,因此应该没问题。
running = false;
countdownTimer.cancel();
关于android - 倒计时 onfinish();取消后仍然调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36688159/
是否可以使用标准输入/标准输出在 bash 中压缩/解压缩字符串? 我试过了,但显然不支持它? hey=$(echo "hello world" | gzip -cf) echo $hey # ret
我的任务是让一个企业网站适用于 IE7,它必须“足够好”,因此我禁用了任何导致问题的花哨/非必要功能。 其中之一是正在使用的搜索栏,需要进行哪些搜索,我猜测幕后某个地方有某种 JavaScript 用
我有一个执行大量处理的小程序。您可以通过按回车键打印进度。 我实现它的方法是在主线程中完成处理,同时我有一个 pthread 不断循环 getchar() 以等待输入键。 问题是当我完成处理时。发生这
我完全理解 suspendCoroutine 与 suspendCancellableCoroutine 在我的示例中的工作方式。但我想知道为什么 println("I finished") (第 1
我是 QT 的新手。目前在我的项目中我实现了 QFileDialog . 在我的用例中:每当用户选择一个文本文件时,它都会执行 functionA .但是,我发现如果在文件对话框中单击取消,funct
我有代码,仅在用户选择“另存为”时运行。为此并获取我正在使用的文件的新名称 Application.GetSaveAsFilename功能。 我遇到的问题是类型不匹配,同时检查用户是否在他没有这样做时
我的 UILocalNotification 有问题。 我正在用我的方法安排通知。 - (void) sendNewNoteLocalReminder:(NSDate *)date alrt:(NS
祝你有美好的一天 我有一个网站,其中有很多“工具提示”。这些工具提示是在将鼠标悬停在文本的特定部分上时创建的。工具提示是一个 div block ,它显示在网站上所有其他内容的顶部,并且当光标从文本移
我遇到以下问题。每隔 2 秒,程序就会进入 if 语句。在这个 if 语句中,我想要一个计时器,它会在 15 秒后给我一条消息。计时器应延迟 1 秒运行。但是当我用计时器“等待”时,if 语句将再执行
基本上我有以下代码片段, (let [task (FutureTask. fn) thr (Thread. task)] (.start thr) ;;wait for signa
取消正在进行的 ASIHttpRequest 请求的正确位置在哪里?这就是我取消的方式,但是当我 时它继续崩溃在不让请求完成的情况下从一个 View Controller 转移到另一个 View Co
我在我的 winforms 应用程序中使用 BackgroundWorker 来执行另一个类中发生的长时间运行的任务(执行数据库操作)。由于所有工作都是在另一个类中完成的,因此取消并不那么简单。我在另
我正在使用 OneSignal 向我的用户显示通知。通知工作正常,但我注意到,如果我在通知栏中“滑动”取消通知,则通知将永远保留,这是一张显示应用程序图标上的通知的图像,我想在应用程序已打开: 我看到
正在运行的 AsyncTask 的 .cancel(boolean) 方法如何工作?这是文档: Attempts to cancel execution of this task. This atte
我注意到,当我激活约束时,我会立即在该行代码处收到一条警告,指出不能同时满足约束。 我假设布局是在“UI 更新周期”之类的稍后时间点计算的,而不是每次约束都被(取消)激活。因此,在(取消)激活约束的代
这是我创建线程的方式: readFromWebThread = [[NSThread alloc] initWithTarget:self selector:@selector(loadThread:
我目前正在尝试取消与我的数据模型中的对象关联的特定 UILocalNotifications。为此,每个数据对象都有一个唯一标识符,即 NSUUID。 创建 UILocalNotification:
当我提交并单击“确定”时,它会继续,但当我按“取消”时,它仍然会提交。我尝试使用此代码,但提交和取消按钮仍然执行相同的操作。 model.saveForm = function() { var
我有一个警报弹出窗口,当发生特定操作时会出现该弹出窗口。 5 秒后,使用 setTimeout() 隐藏警报弹出窗口。 我遇到的问题是,如果我多次触发弹出窗口,有时后续的弹出窗口会出现但立即消失。我相
我有一些 javascipt (jQuery),其中单击按钮时会淡入 #myDiv,然后使用超时函数在 5 秒后再次淡出。它工作正常,但如果用户在超时内的 fadeOut 函数运行之前再次单击该按钮,
我是一名优秀的程序员,十分优秀!