Im sử dụng DataBinding
Api để đặt chế độ xem trong bố cục Android. Đây là cách bố trí của tôi.Tôi muốn concat hai chuỗi cho một TextView trong android, Binding dữ liệu Api
Layout.xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable name="user" type="testing.sampleapp.com.sampleapp.User"/>
</data>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{ "Hello " + user.firstName}"/>
</LinearLayout>
Tôi muốn các TextView để hiển thị Xin chào UserName. Làm thế nào để đạt được điều này bằng cách sử dụng api ràng buộc dữ liệu.
Đúng vậy. Cảm ơn . Tôi đã sử dụng dấu phẩy ngược đơn ('). Grave accent (') làm việc cho tôi. –
@SasankSunkavalli rất vui được giúp bạn :), luôn sử dụng dấu trọng âm cho chuỗi khi sử dụng DataBinding. –