如何在数据绑定中不将参数传递给具有默认值的参数

Dev*_*cie 5 android android-xml kotlin android-databinding

是否可以在不传递参数的情况下使用 XML 中的默认参数调用 Kotlin 函数

这是我的视图模型:

class MyViewModel: ViewModel(){

    fun doSomething(myVar: String = "defValue"){

    }
}
Run Code Online (Sandbox Code Playgroud)

XML:

....
<data>
    <variable
        name="viewModel"
        type="com.example.MyViewModel" />
</data>
....
android:onClick="@{(view) -> viewModel.doSomething()}"  --> ERROR
android:onClick="@{(view) -> viewModel.doSomething(`SomeString`)}"  --> WORKING
....
Run Code Online (Sandbox Code Playgroud)

当我使用数据绑定从 XML调用不带参数doSomething方法时,出现错误。

[databinding] {"msg":"cannot find method doSomething() in class com.example.MyViewModel","file":"app\\src\\main\\res\\layout\\fragment_list.xml","pos":[{"line0":56,"col0":41,"line1":56,"col1":65}]}
Run Code Online (Sandbox Code Playgroud)