I want to concat two strings for a TextView in android, Data Binding Api

前端 未结 10 833
太阳男子
太阳男子 2020-12-23 14:04

Im using DataBinding Api for setting the views in android layouts. Here is my layout.

layout.xml



        
10条回答
  •  心在旅途
    2020-12-23 14:49

    There are two ways.

    First Solution

    concat with grave accent (`)

    android:text="@{`Hello ` + user.firstName}"/>
    

    Second Solution

    Declare Your string in strings.xml

    like "Hello %1$s , (whatever you want to add then add here)".

    amd use String.format(stringResource, upsatename);

提交回复
热议问题