今天再看一个Android LunchList的tutorial
发现有两种写法:
都是在 LunchList 这个类里,不同的方法
new Intent(this, EditPreferences.class);
和
new Intent(LunchList.this, DetailForm.class);
LunchList.this和this有什么区别?
今天再看一个Android LunchList的tutorial
发现有两种写法:
都是在 LunchList 这个类里,不同的方法
new Intent(this, EditPreferences.class);
和
new Intent(LunchList.this, DetailForm.class);
LunchList.this和this有什么区别?
这应该是在内部类里面调用的吧
如果在内部类里面的this就是这个内部类的实例,而OuterClassName.this就是它外面的那个类的实例
看起来是Android编程吧,应该是写了一个listener的匿名类?
如果是的话,那么this就是指这个listener实例,而LunchList.this就是外面的类,可能是Activity吧
2 回答1.5k 阅读✓ 已解决
2 回答1.9k 阅读
3 回答673 阅读✓ 已解决
1 回答2.2k 阅读
1 回答906 阅读✓ 已解决
1 回答1.4k 阅读
1 回答613 阅读✓ 已解决
如果你的程序里面包含了内部匿名类之类,比如线程