Android Two Way DataBinding Problem of Ternary Operator Must be Constant

后端 未结 2 1632
一生所求
一生所求 2020-12-20 06:48

My EditText is like this:



        
2条回答
  •  不知归路
    2020-12-20 07:32

    You need to remove the equal sign before the starting curly brace

    android:text="@{viewModel.isAddCase ? ``: `` + viewModel.currentStudent.age}"    
    

    Also you can use String.valueOf instead of the ``

    android:text="@{viewModel.isAddCase ? ``: String.valueOf(viewModel.currentStudent.age)}"    
    

提交回复
热议问题