android xml标签字符串组合

tom*_*136 3 android android-layout

如何连接两个字符串?

<TextView android:text="@string/app_name.@string/app_version" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="center" android:layout_alignParentLeft="true" android:id="@+id/Welcome" android:textSize="34px"></TextView>
Run Code Online (Sandbox Code Playgroud)

机器人:文本= "@字符串/ APP_NAME @字符串/ APP_VERSION"

模拟器直接打印"@ string/app_name.@ string/app_version"而不是它应该是类似"APP 1.2"的字符串

Smu*_*rik 5

你不能这样做,如果你想在TextView中使用两个字符串,你必须以编程方式设置文本:

TextView tv = (TextView)findViewById(R.id.welcome);
tv.setText(getString(R.string.app_name) + getString(R.string.app_version));
Run Code Online (Sandbox Code Playgroud)