【发布时间】:2018-03-15 07:51:47
【问题描述】:
我使用 Anko DSL 创建 UI 而不是 XML。但是当我要以 Anko 方式设置单选按钮的 layout_weight 参数时,我遇到了错误。
我尝试了以下方法:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
verticalLayout() {
radioGroup() {
orientation = LinearLayout.HORIZONTAL
radioButton {
id = RADIO_SECOND
text = "second(s)"
}.lparams(width = wrapContent, height = wrapContent, weight = 0.25F)
// Few more radio button
}
}
}
但它给出了错误Error:(107, 19) 'inline fun <T : View> RadioButton.lparams(width: Int = ..., height: Int = ..., weight: Float): RadioButton' can't be called in this context by implicit receiver. Use the explicit one if necessary。
我该如何继续?
【问题讨论】:
-
你在什么上下文中使用它?那么基本上你的 sn-p 周围有什么代码?
-
@creativecreatorormaybenot 我已经用周围的代码更新了帖子。
标签: android kotlin kotlin-android-extensions anko