简体   繁体   中英

How to check for null objects in databinding android using null coalescing operator

在此处输入图像描述

How do I check for user.= null using null coalescing operator. The android documentation shows if user.displayName is null then lastName will be used? But what if user is null?

How to add null check for user object in the following code?

android:text="@{user.displayName?? user.lastName}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM