android - getApplicationContext 和 classname.this 的区别

标签 android android-context

当我使用 ListView 并且我有一个自定义的基本适配器类时,当基本适配器由 getApplicationContextclassname.this。 通过 getApplicationContext 我得到白色文本颜色但是 classname.this 是黑色的。谁能为我解释一下?

最佳答案

基本上它们都是 Context 的实例,但区别在于应用程序实例与应用程序的生命周期相关联,而 Activity 实例与 Activity 的生命周期相关联。因此,他们可以访问有关应用程序环境的不同信息......

参见 getApplicationContext

编辑

在寻找答案时,它将帮助您 Android Holo Light styling changes depending on chosen context

关于android - getApplicationContext 和 classname.this 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16141369/

相关文章:

android - 将 android drawable 添加到菜单 XML 停止应用程序编译

java - 如何覆盖Gson默认的DateTypeAdapter?

android - 如何在 ViewPager 位置偏移量变化时为 View 设置动画

java - 在安卓上创建一个文件

android - 在 FragmentPagerAdapter 中使用上下文

android - 在 Android 中使用 arcTo 创建凹路径

android - 将 Activity Context 存储在 DialogFragment 中会导致内存泄漏吗?

android - 在 View 上下文中获取 Activity 对象

java - 如何在Android中通过上下文添加 View

java - 如何使用 Retrofit android 设置工具栏标题?