在XML中实现点击属性,并传递一种将视图作为参数的方法

问题描述 投票:0回答:1

我已经在XML文件中自己的自定义类型的数据标记内创建了一个变量

<data>
        <variable
            name="gameViewModel"
            type="com.example.andriod.splock.screens.game.GameViewModel" />
</data>

此类的变量具有将视图作为参数的方法choicemade(view : View)

我无法通过it作为我的图像视图的参考

以下代码显示无法找到标识符方法

<imageView
  ...
android:onClick="@{() -> gameViewModel.choicemade(it)}"/>

如何传递图像视图的参考?

android function kotlin attributes parameter-passing
1个回答
0
投票

尝试这种方式

© www.soinside.com 2019 - 2024. All rights reserved.