Android

[Adroid] view.context

Forest Yun 2021. 6. 18. 18:15
728x90

view.context

= this

java: View.getContext

โ€‹

/**

* Returns the context the view is running in, through which it can

* access the current theme, resources, etc.

*

* @return The view's Context.

*/

โ€‹

: ํ˜„์žฌ ์‹คํ–‰๋˜๊ณ  ์žˆ๋Š” ๋ทฐ์˜ context๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

this๋ผ๊ณ  ๋Œ€์‹  ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ this๋Š” ํ˜„์žฌ ์•กํ‹ฐ๋น„ํ‹ฐ์—์„œ์˜ this๋ฅผ ์˜๋ฏธํ•˜๋ฏ€๋กœ, ํ˜„์žฌ ์ž์‹ ์ด ์œ„์น˜ํ•œ ๊ณณ์— ๋”ฐ๋ผ this๋Š” ๋‹ฌ๋ผ์ง„๋‹ค.

val intent = Intent(this, MainActivity::class.java).show() 
startActivity(intent)

โ€‹

โ€‹

์˜ˆ)ClickableSpan์˜ onClick ๋ฉ”์†Œ๋“œ๋ฅผ ์žฌ์ •์˜ํ•  ๋•Œ์˜ this๋Š” ํ˜„์žฌ Activity๋ฅผ ์˜๋ฏธํ•˜๋Š”๊ฒƒ์ด ์•„๋‹ˆ๋ผ ClickableSpan์„ ์˜๋ฏธํ•œ๋‹ค.

โ€‹

โ€‹

728x90