android-通过kotlin-extensions更改自动创建视图的名称的任何方法?

android-通过kotlin-extensions更改自动创建视图的名称的任何方法?,第1张

概述我是科特林的新手.我已将红色设置为https://kotlinlang.org/docsutorials/android-plugin.html,并注意到可以通过导入将视图自动绑定到活动中kotlinx.android.synthetic.main.activity_main.*.如果我在Activity中声明id为“btn_login”的视图,则可以通过以下方式访问它acti

我是科特林的新手.我已将红色设置为https://kotlinlang.org/docs/tutorials/android-plugin.html,并注意到可以通过导入将视图自动绑定到活动中
kotlinx.androID.synthetic.main.activity_main.*.

如果我在Activity中声明ID为“ btn_login”的视图,则可以通过以下方式访问它

activity.btn_login.setText(“Login”)

但.有什么办法可以更改别名以进行查看,例如ButterKnife可以:

@BindVIEw(<ID of vIEw>)<name of vIEw></k>

解决方法:

这是一种合成导入,因此从技术上讲,您可以使用导入别名以其他名称进行调用:

import kotlinx.androID.synthetic.main.activity_main.vIEw.btn_login as btnLogin

但是考虑到没有工具可以自动执行此 *** 作,您可能希望采用其他ID命名方案.

这是一个合理的选择:

What-Where-Description-ModifIEr:

recyclerSearchSuggestions – RecyclerVIEw showing search suggestions

fabSearchGo – floatingActionbutton that executes a search

textSearchFilterChip – TextVIEw that represents search filters, styled as a material chip

buttonSearchClearFilter – button that clears selected filter chips

editSearchFilter – EditText used to narrow down search suggestions

总结

以上是内存溢出为你收集整理的android-通过kotlin-extensions更改自动创建视图的名称的任何方法?全部内容,希望文章能够帮你解决android-通过kotlin-extensions更改自动创建视图的名称的任何方法?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1210125.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-04
下一篇2022-06-04

发表评论

登录后才能评论

评论列表(0条)

    保存