Escape And(&&) Operator In Android Data Binding

March 11, 2018

The following operator need to be escaped (XML escaped characters):

  • & -> &
  • < -> &lt;
  • > -> &gt;
  • " -> &quot;
  • ' -> &apos;

android:visibility="@{!viewModel.isEdit &amp;&amp; viewModel.categoryIdItemPosition != 0 ? View.VISIBLE : View.GONE}"

android:visibility="@{viewModel.categoryIdItemPosition &gt; 0 ? View.VISIBLE : View.GONE}"

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.