Attempt to invoke virtual method: void android.widget.Button.setTag(java.lang.Object)
on a null object reference.
error when I use androiddataBinding
on Button like:
<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="50dp"
android:background="@{userInfo.isEmpty?@drawable/shape_gray_corner:@color/colorWhite}"
android:text="@string/text_login"
android:onClick="onViewClik"
android:textColor="@color/colorWhite"
android:textSize="@dimen/textsize_24" />
I think you have to try default color instead of drawable or use drawable at both places.
like this
android:background="@{userInfo.isEmpty ? @color/colorYellow : @color/colorWhite}"
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.