how to call another intent from countdown timer finish method?

后端 未结 1 1755
-上瘾入骨i
-上瘾入骨i 2021-01-17 06:15

I am working on android quiz. In my code i have countdown timer when time finish i want next question came and score are decreases (for score decrement currentGame.decrement

1条回答
  •  孤街浪徒
    2021-01-17 07:05

    Create a new method say processScreen() and insert data of onCreate inside it so that you can call this method, repeatedly with having to call same activity again..(its a workaround..)

    private void processScreen(){
            /**
             * Configure current game and get question
             */
            currentGame = ((CYKApplication)getApplication()).getCurrentGame();
            currentQ = currentGame.getNextQuestion();
            Button nextBtn1 = (Button) findViewById(R.id.answer1);
            nextBtn1.setOnClickListener(this);
            Button nextBtn2 = (Button) findViewById(R.id.answer2);
            nextBtn2.setOnClickListener(this);
            Button nextBtn3 = (Button) findViewById(R.id.answer3);
            nextBtn3.setOnClickListener(this);
            Button nextBtn4 = (Button) findViewById(R.id.answer4);
            nextBtn4.setOnClickListener(this);
            Button nextBtn5 = (Button) findViewById(R.id.answer5);
            nextBtn5.setOnClickListener(this);
            /**
             * Update the question and answer options..
             */
            setQuestions();
    }
    

    so now your onCreate becomes

     @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.question);
            processScreen();
    }
    

    Now, call processScreen() instead of calling QuestionActivity again in onClick of your button. In other words, contents will be refreshed..

    Hope this helps..

    0 讨论(0)
提交回复
热议问题