An error comes up saying Cannot resolve symbol ‘Gravity’. Please help me figure this Gravity issue out. The QuizActivity.java looks like this:
package com.bignerdranch.android.geoquiz;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class QuizActivity extends AppCompatActivity {
private Button mTrueButton;
private Button mFalseButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz);
mTrueButton = (Button) findViewById(R.id.true_button);
mTrueButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Toast.makeText(QuizActivity.this,R.string.correct_toast,Toast.LENGTH_SHORT).show();
Toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 0);
}
});
mFalseButton = (Button) findViewById(R.id.false_button);
mFalseButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Toast.makeText(QuizActivity.this,R.string.incorrect_toast,Toast.LENGTH_SHORT).show();
Toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 0);
}
});
}
}
The debug log says this:
Error:(25, 34) error: cannot find symbol variable Gravity
Error:(25, 46) error: cannot find symbol variable Gravity
Error:(25, 22) error: non-static method setGravity(int,int,int) cannot be referenced from a static context
Error:(33, 34) error: cannot find symbol variable Gravity
Error:(33, 46) error: cannot find symbol variable Gravity
Error:(33, 22) error: non-static method setGravity(int,int,int) cannot be referenced from a static context
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Thanks.