timer 相关问题

计时器是一种控件,具有按用户配置的定期间隔触发用户定义的操作的功能。




如何在vue.js

这只是我正在使用的原型代码,以帮助我学习vue.js,我真的需要帮助它才能正常工作。您能告诉我一种简单的方法吗?我仍然是新手,所以我只想要一些容易理解的东西。

回答 1 投票 0

你可以帮忙吗?

回答 0 投票 0

STM32G4TIM1中心对齐PWM更新事件问题

如何确保更新事件仅在此模式下发生在ARR上?

回答 0 投票 0

jest settimeout不暂停测试

IT('有工作挂钩',async()=> { settimeout(()=> { console.log(“我为什么不跑?”) 期待(true).tobe(true) },15000) 我已经回顾了这个答案,开玩笑的文件,...

回答 4 投票 0



我已经提出了一个测验申请,其中包括5个问题。我制作了一个结果,该页面显示了测验的结果。 我为每个问题添加了20秒的倒计时计时器。倒数计时器完成后,它会自动移至下一个问题。问题完成后,应移至结果页面以显示结果。 我只有一个问题... afet遇到了我的最后一个问题。如果我没有选择任何答案,并且计时器完成,则应用程序没有转移到我的结果效率页面。 我的代码是我的代码:

package com.example.triviality; import java.util.LinkedHashMap; import java.util.List; import android.os.Bundle; import android.os.CountDownTimer; import android.app.Activity; import android.content.Intent; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; import android.widget.Toast; public class QuizActivity extends Activity { List<question> quesList; public static int score, correct, wrong, wronganswers; public boolean isCorrect; static int qid = 0; int totalCount = 5; Question currentQ; TextView txtQuestion; RadioGroup radioGroup1; RadioButton rda, rdb, rdc; Button butNext; TextView rt; boolean nextFlag = false; boolean isTimerFinished = false; static LinkedHashMap lhm = new LinkedHashMap(); MyCountDownTimer countDownTimer = new MyCountDownTimer(10000 /* 20 Sec */, 1000); // final MyCountDownTimer timer = new MyCountDownTimer(20000,1000); public static String[] Correctanswers = new String[5]; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_quiz); DbHelper db = new DbHelper(this); quesList = db.getAllQuestions(); currentQ = quesList.get(qid); txtQuestion = (TextView) findViewById(R.id.textView1); rda = (RadioButton) findViewById(R.id.radio0); rdb = (RadioButton) findViewById(R.id.radio1); rdc = (RadioButton) findViewById(R.id.radio2); butNext = (Button) findViewById(R.id.button1); // radioGroup1=(RadioGroup)findViewById(R.id.radioGroup1); setQuestionView(); // timer.start(); rt = (TextView) findViewById(R.id.rt); rt.setText("20"); countDownTimer.start(); butNext.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { countDownTimer.cancel(); if (getNextQuestion(false)) { // Start The timer again countDownTimer.start(); } } }); } private void setQuestionView() { txtQuestion.setText(currentQ.getQUESTION()); rda.setText(currentQ.getOPTA()); rdb.setText(currentQ.getOPTB()); rdc.setText(currentQ.getOPTC()); } public class MyCountDownTimer extends CountDownTimer { public MyCountDownTimer(long startTime, long interval) { super(startTime, interval); } public void onFinish() { Log.e("Times up", "Times up"); countDownTimer.cancel(); if (getNextQuestion(false)) { // Start The timer again countDownTimer.start(); } } @Override public void onTick(long millisUntilFinished) { rt.setText((millisUntilFinished / 1000) + ""); Log.e("Second Gone", "Another Second Gone"); Log.e("Time Remaining", "seconds remaining: " + millisUntilFinished / 1000); } } boolean getNextQuestion(boolean c) { nextFlag = true; RadioGroup grp = (RadioGroup) findViewById(R.id.radioGroup1); // grp.clearCheck(); RadioButton answer = (RadioButton) findViewById(grp .getCheckedRadioButtonId()); if (rda.isChecked() || rdb.isChecked() || rdc.isChecked()) { qid++; Log.d("yourans", currentQ.getANSWER() + " " + answer.getText()); grp.clearCheck(); // wronganswers= if (!c && currentQ.getANSWER().equals(answer.getText())) { correct++; } else { lhm.put(currentQ.getQUESTION(), currentQ.getANSWER()); wrong++; } if (qid < 5) { currentQ = quesList.get(qid); setQuestionView(); } else { score = correct; Intent intent = new Intent(QuizActivity.this, ResultActivity.class); Bundle b = new Bundle(); b.putInt("score", score); // Your score intent.putExtras(b); // Put your score to your next Intent startActivity(intent); return false; } } else { lhm.put(currentQ.getQUESTION(), currentQ.getANSWER()); qid++; if (qid < 5) { currentQ = quesList.get(qid); //currentQ.getANSWER().equals(wrong); wrong++; Log.e("yourans", currentQ.getANSWER()); setQuestionView(); } // wrong++; // Log.e("Without Any Selection ", "without "+wrong); // Toast.makeText(getApplicationContext(), // "Please select atleast one Option",Toast.LENGTH_SHORT).show(); } return true; } } ResultActivity.java: package com.example.triviality; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class ResultActivity extends Activity { Button restart; Button check; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_result); TextView t=(TextView)findViewById(R.id.textResult); TextView t1=(TextView)findViewById(R.id.textResult1); TextView t2=(TextView)findViewById(R.id.textResult2); restart=(Button)findViewById(R.id.restart); check=(Button)findViewById(R.id.check); StringBuffer sb=new StringBuffer(); sb.append("Correct ans: "+QuizActivity.correct+"\n"); StringBuffer sc=new StringBuffer(); sc.append("Wrong ans : "+QuizActivity.wrong+"\n"); StringBuffer sd=new StringBuffer(); sd.append("Final Score : "+QuizActivity.score); t.setText(sb); t1.setText(sc); t2.setText(sd); QuizActivity.correct=0; QuizActivity.wrong=0; check.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent in=new Intent(getApplicationContext(),CheckActivity.class); startActivity(in); } }); restart.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //QuizActivity quiz=new QuizActivity(); // TODO Auto-generated method stub Intent intent=new Intent(getApplicationContext(),QuizActivity.class); QuizActivity.lhm.clear(); QuizActivity.qid=0; startActivity(intent); //quiz.countDownTimer.onTick(19); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_result, menu); return true; } }

回答 1 投票 0

STM8TIMER1故障或停滞问题

Timer错误1在STM8S003F3P中 我正在编写代码以创建溢出1 =计时器1,以将剩余的_sec变量从60减少到1。但是计时器通常会随机悬挂一段时间。 例如,...

回答 1 投票 0





如何创建一个24小时的计时器?

我想创建一个24小时的销售计时器并在“内部”按钮中显示。我正在使用此代码,但不知道如何停止此计时器。 这是我的代码。在此示例中,我使用35秒来更快地测试:...

回答 1 投票 0

定时器与线程(Zephyr RTOS)-哪个更合适?

嗨,我已经使用 RTOS 环境一段时间了(FreeRTOS 和 Zephyr),我想知道,一般来说,RTOS 计时器是否被认为比线程更轻量级。我包括...

回答 1 投票 0

STM32F427 使用单 DMA 流控制 TIM4 通道(PWM)

我正在尝试使用 DMA 控制 PWM 信号的所有 4 个 TIM4 引脚。我可以使用单个 DMA 流将数据发送到每个引脚吗? 当我在 STM32 IDE 中设置引脚和 DMA 时,它将 TIM4 通道 1 引脚链接到 D...

回答 1 投票 0

使用love2d计时器,错误报告'Error hump/timer.lua:78: attempts to index local 'self' (a number value) '

下面是可能出现错误的地方 这是我的 main.lua,我记下我认为错误的地方。我想不通的是为什么这句话会返回一个数字值? 我正在学习Downwel...

回答 1 投票 0

为什么我的 Timer 类在连续无延迟启动时没有执行?

我有一个 C++ 中的自定义 Timer 类,它使用 std::async 在单独的线程中运行计时器。我面临的问题是,当我连续无延迟地对同一个 Timer 对象调用 start() 时,...

回答 1 投票 0

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.