getApplicationContext和classname.this的区别 [英] Difference between getApplicationContext and classname.this
问题描述
当我使用列表视图,我有一个自定义的底座适配器类,我得到的列表视图不同的文字颜色时,基本适配器是由 getApplicationContext
实例化和 classname.this
。
通过 getApplicationContext
我得到的白色文字的颜色,但 classname.this
是黑色的。谁能解释一下吗?
When I'm using list view and I have a custom Base Adapter class, I get different text color in list view when base adapter is instantiated by getApplicationContext
and classname.this
.
By getApplicationContext
I get white text color but classname.this
is black. Can anyone explain it for me?
推荐答案
他们基本上是上下文的两个实例,但不同的是应用程序实例绑定到应用程序的生命周期,而活动实例绑定到生命周期一个活动。因此,他们有机会获得对应用环境的不同信息......
Basically they are both instances of Context, but the difference is application instance is tied to the lifecycle of the application, while the Activity instance is tied to the lifecycle of an Activity. Thus, they have access to different information about the application environment...
看<一href="http://developer.android.com/reference/android/content/ContextWrapper.html#getApplicationContext%28%29"相对=nofollow> getApplicationContext
修改
在找到你的答案将会有助于你的Android根据所选的上下文全息光造型变化
In finding your answer it will help you Android Holo Light styling changes depending on chosen context
这篇关于getApplicationContext和classname.this的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!