吐司没有出现

Toast doesn't appear

所以,我有 import android.widget.toast,编译时没有收到任何错误。但是,以下内容:

private void checkAnswer(boolean userPressedTrue){
    boolean isAnswerTrue = mQuestionBank[mCurrentIndex].isTrueQuestion();

    int messageResId = 0;

    if (userPressedTrue == isAnswerTrue){
        messageResId = R.string.correct_toast;
    } else {
        messageResId = R.string.incorrect_toast;
    }

    Toast.makeText(this.getApplicationContext(), messageResId, Toast.LENGTH_SHORT);

}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quiz);

    mQuestionTextView = (TextView) findViewById(R.id.question_text_view);

    mTrueButton = (Button) findViewById(R.id.true_button);
    mTrueButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkAnswer(true);
        }
    });
    mFalseButton = (Button) findViewById(R.id.false_button);
    mFalseButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkAnswer(false);
        }
    });

不显示在我的 phone 上。我确保没有为该应用禁用通知。

您需要在 makeText() 之后调用 show() 方法;

    Toast.makeText(this.getApplicationContext(), messageResId, Toast.LENGTH_SHORT).show();