我想为Android中的TextView合并两个字符串,数据绑定Api [英] I want to concat two strings for a TextView in android, Data Binding Api
本文介绍了我想为Android中的TextView合并两个字符串,数据绑定Api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用DataBinding
Api在android布局中设置视图.这是我的布局.
Im using DataBinding
Api for setting the views in android layouts. Here is my layout.
layout.xml
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>
我希望TextView显示你好用户名.如何使用数据绑定API实现此目标.
I want the TextView to display Hello UserName. How to achieve this using the data binding api.
推荐答案
用重音(`)
android:text="@{`Hello ` + user.firstName}"/>
您可以通过多种方式连接它,在此处进行检查在数据视图中使用数据绑定来连接两个字符串
You can concat it in multiple ways, check it here concat-two-strings-in-textview-using-databinding
这篇关于我想为Android中的TextView合并两个字符串,数据绑定Api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文