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,这样就不会出问题了。

posted @ 2015-02-14 11:26  德玛西亚冲锋  阅读(432)  评论(0编辑  收藏  举报