Android 开发笔记 “The constructor AlertDialog.Builder(new View.OnKeyListener(){}) is undefined”

1、The constructor AlertDialog.Builder(new View.OnKeyListener(){}) is undefined等,应该有很多类似问题

比如你的源码文件名是 Activity.java,就改成
Dialog dialog=new AlertDialog.Builder(Activity.this);
因名称而异。在listener中的this指代的并不是Activity里的this,而两个this成员和方法是完全不一样的,所以会出错,需要告诉IDE即将访问的是Activity的this,这样就不会出问题了。

原文地址:https://www.cnblogs.com/Dylanblogs/p/4291386.html