有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

调用后未更新void方法中的java setText?

@Override
        public void onAnimationEnd(Animation animation) {
            Toast.makeText(PlayQuiz.this, "END", Toast.LENGTH_SHORT).show();

            //Show next question
            showNextQuestion();
            mOptionTwoTextView.setText("Hell Yeah");
        }


private void showNextQuestion() {

        mThisQuestion = mDummyQuestionList.get(mTHisQuestionID++);
        //Set Questions and Options
        mQuestionTextView.setText(mThisQuestion.getQuestion());
        mOptionOneTextView.setText(mThisQuestion.getOptionOne());
        mOptionTwoTextView.setText(mThisQuestion.getOptionTwo());
        mOptionThreeTextView.setText(mThisQuestion.getOptionThree());
        mOptionFourTextView.setText(mThisQuestion.getOptionFour());
    }

在animationEnd中,设置的文本工作正常,但调用此void后,它应该会更改文本,但不会更改文本


共 (1) 个答案

  1. # 1 楼答案

    @Override
    public void onAnimationEnd(Animation animation) {
      
        // execute methods in main thread
        new Handler(Looper.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
    
                Toast.makeText(PlayQuiz.this, "END", Toast.LENGTH_SHORT).show();
                showNextQuestion();
                mOptionTwoTextView.setText("Hell Yeah");
                
            }
        });
    
    }