什么意思了"这&Q​​UOT;背景? [英] What's meant by the "this" context?

查看:185
本文介绍了什么意思了"这&Q​​UOT;背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过了很多的android教程在互联网上。在这些教程中,他们使用了上下文语境无处不在。我知道关键字意味着在Java中,但我不能让这种平等,在Android上关键词编程。例如,在 AlertDialog.Builder ,在developer.android.com现场,只有一个在参数上下文的参考,但我无法了解这是什么这里的意思。

I have looked at a lot of android tutorials over the internet. In these tutorials they use the this context for the context everywhere. I know what this keyword means in Java, but I can't make equal this, with the this keyword in Android programming. For example, at AlertDialog.Builder, on the developer.android.com site, there is only one reference at the parameters to the Context, but I can't learn what this this means here.

推荐答案

如果你有一个活动,您可以使用,因为:

if you have an Activity you can use this because:

  • 是一个类
  • 的当前实例
  • 在一个活动是从类上下文继承
  • this is the current instance of a class
  • an Activity is inherits from the class "Context"

所以你可以使用你当前活动的上下文。

so you can use your current Activity as a Context.

看这里的Acitivty文档: <一href="http://developer.android.com/reference/android/app/Activity.html">http://developer.android.com/reference/android/app/Activity.html

Look here for the Acitivty doc: http://developer.android.com/reference/android/app/Activity.html

和这里的解释: <一href="http://download.oracle.com/javase/tutorial/java/javaOO/thiskey.html">http://download.oracle.com/javase/tutorial/java/javaOO/thiskey.html

这篇关于什么意思了&QUOT;这&Q​​UOT;背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆