AlertDialog不兼容的类型错误

Mic*_*ins 2 java android android-sdk-tools

我一直在尝试编译这个简单的警告对话框,以便在用户单击提交按钮时显示.编译代码时会弹出一条错误消息:

错误:(33,74)错误:不兼容的类型:<anonymous OnClickListener>无法转换为Context

这个类叫做Login_Activity,它扩展了BaseActivity,扩展了Activity.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    mUserNameEt = (EditText) findViewById(R.id.login_username_et);
    mPasswordEt = (EditText) findViewById(R.id.login_password_et);
    mSubmitBtn = (Button) findViewById(R.id.login_submit_btn);

    mSubmitBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            AlertDialog.Builder messageBox = new AlertDialog.Builder(this);
            messageBox.setTitle("Atlas Box");
            messageBox.setMessage("Dictionary.");
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

sas*_*mar 7

更改

AlertDialog.Builder messageBox = new AlertDialog.Builder(this);
Run Code Online (Sandbox Code Playgroud)

AlertDialog.Builder messageBox = new AlertDialog.Builder(youractivityname.this);
Run Code Online (Sandbox Code Playgroud)