Reputation: 307
So, I have import android.widget.toast
, and I receive no errors when compiling. However, the following:
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);
}
});
does not display on my phone. I made sure that notification weren't disabled for the app.
Upvotes: 1
Views: 369
Reputation: 3665
you need to call show() method after makeText();
Toast.makeText(this.getApplicationContext(), messageResId, Toast.LENGTH_SHORT).show();
Upvotes: 4