“此"表示什么?语境? [英] What's meant by the "this" context?

查看:65
本文介绍了“此"表示什么?语境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在互联网上看了很多android教程.在这些教程中,他们将 this 上下文用于所有上下文.我知道 this 关键字在Java中的含义,但我无法与Android编程中的 this 关键字等同.例如,在developer.android.com网站上的 AlertDialog.Builder 上,上下文参数只有一个引用,但是我无法了解此 this 就是这里.

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.

推荐答案

如果您有活动",则可以使用 this ,因为:

if you have an Activity you can use this because:

  • this 是一个类的当前实例
  • 活动是从上下文"类继承的.

因此您可以将当前的活动用作上下文.

so you can use your current Activity as a Context.

此处查找Acitivty文档

Look here for the Acitivty doc

此处以获取对的解释这个

这篇关于“此"表示什么?语境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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