I don't understand why my toast is crashing the app.
I have two sets of code, the one I originally did which is crashing and one that I found that is working.
The one the is working creates the toast object and declares the text at the same time.
Toast toast =
Toast.makeText(QuizActivity.this,R.string.incorrect_toast, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
The one I made creates the object in the context, sets the text then the gravity and tries to show it.
Toast toast = new Toast(QuizActivity.this);
toast.makeText(QuizActivity.this,
R.string.correct_toast,
Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
Why is this crashing my app?