【问题标题】:Context in Android Programming [duplicate]Android编程中的上下文[重复]
【发布时间】:2011-04-07 19:44:33
【问题描述】:

可能重复:
What is Context in Android?

谁能告诉我android中使用的“上下文”术语。我想知道这到底意味着什么,因为这是我以前在很多地方看到的东西。

我发现它是一个类:-“关于应用程序环境的全局信息的接口”,但我现在还不太清楚。

例如: 公共GetCurrentLocation(上下文上下文) { this.context = 上下文; }

谢谢, 大卫

【问题讨论】:

    标签: android


    【解决方案1】:

    我已经回答了here

    this.context = context 写得很混乱。另一种写法:

    public class LocationClass {
    
    private Context context_belonging_to_class = null;
    
    // ..
    
    public GetCurrentLocation(Context context_from_call_entity) {
      context_belonging_to_class = context_from_calling_entity; // initializing context variable
    }
    
    // ..
    
    }
    

    【讨论】:

    • 感谢您的回答,它帮助我更好地理解了上下文类。
    猜你喜欢
    • 2012-08-09
    • 1970-01-01
    • 2015-02-28
    • 2013-06-08
    • 1970-01-01
    • 2012-12-17
    • 2010-12-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多