
我是科特林的新手.我已将红色设置为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更改自动创建视图的名称的任何方法?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)