Android DataBinding where to get context?

后端 未结 3 995
心在旅途
心在旅途 2020-12-10 10:17

I have TextView for showing time. I want to use Android\'s DataBinding plugin.

For formatting time I am using DateUtils.formatDateTime(context, in

3条回答
  •  天命终不由人
    2020-12-10 10:39

    A special variable named context is generated for use in binding expressions as needed. The value for context is the Context from the root View's getContext(). The context variable will be overridden by an explicit variable declaration with that name.

    In other words, every time you need to pass the context just use "context" as in @{Object.method(context)}.

提交回复
热议问题