android - Android 编程中的上下文

标签 android

<分区>

Possible Duplicate:
What is Context in Android?

任何人都可以告诉我有关 android 中使用的“上下文”术语的信息。我想知道这到底是什么意思,因为这是我以前在很多地方看到的东西。

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

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

谢谢, 大卫

最佳答案

我已经回答了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
}

// ..

}

关于android - Android 编程中的上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3635503/

相关文章:

java - 以编程方式创建的 TextView 未显示

android - Android L 与 Kitkat 中的 RAM 使用情况

android通过代码设置 Activity 方向

android - 创建新项目时出现问题

android启动蓝牙sco不在 Lollipop 中路由麦克风

android - 检测 BaseAdapter.notifyDataSetChanged() 何时完成

android - Fragments之间直接传递复杂数据?代码有什么问题?

android - RxJava 和 Retrofit2 : NetworkOnMainThreadException

android - 如何使 CardView 和 CardView 中的 RecyclerView 具有低项目时的大小

java - 如何遍历 Firebase child 的 child 并将他们的 key 添加到列表中?