Context
来源:互联网 发布:ipad阅读pdf软件 编辑:程序博客网 时间:2024/06/08 05:42
1 Context与ApplicationContext
看了标题,千万不要被误解,ApplicationContext并没有这个类,其实更应该叫做:Activity与Application在作为Context时的区别。嗯,的确是这样的,大家在需要Context的时候,如果是在Activity中,大多直接传个this,当在匿名内部类的时候,因为this不能用,需要写XXXActivity.this,很多哥们会偷懒,直接就来个getApplicationContext。那么大家有没有想过,XXXActivity.this和getApplicationContext的区别呢?
XXXActivity和getApplicationContext返回的肯定不是一个对象,一个是当前Activity的实例,一个是项目的Application的实例。既然区别这么明显,那么各自的使用场景肯定不同,乱使用可能会带来一些问题。
0 0
- Context
- Context
- Context
- context
- Context
- context
- Context
- Context
- Context
- Context
- Context
- Context
- Context
- context
- context
- Context
- Context
- Context
- 菜单
- hdu(2955)——Robberies
- MYSQL线程池总结(一)
- sql语句delete----关联两表删除两表内容
- Android 一般动画Animation和属性动画Animator
- Context
- Java中的数据库处理—增删改查
- debug调试
- 归并排序
- 空格替换(剑指offer+程序员面试金典)+string类知识点讲解
- MySQL线程池总结(二)
- MySQL 存储过程的优缺点
- 华为求字符串最后单词长度
- 洛谷2524 Uim的情人节礼物·其之弐解题报告