今天再看一个Android LunchList的tutorial
发现有两种写法:
都是在 LunchList 这个类里,不同的方法
new Intent(this, EditPreferences.class);
和
new Intent(LunchList.this, DetailForm.class);
LunchList.this和this有什么区别?
解决方案
如果你的程序里面包含了内部匿名类之类,比如线程
class A { public void callSomething(){ new Thread(){ public void run(){ // 这里的this 代表 匿名类的上下文, A.this 代表A实例化后对象的上下文 } }.start(); } }