android xml标签字符串组合

时间:2011-08-16 15:33:44

标签: 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>

机器人:文本= “@串/ APP_NAME @串/ APP_VERSION”

模拟器直接打印“@ string / app_name。@ string / app_version”而不是字符串 它应该像“APP 1.2”

1 个答案:

答案 0 :(得分:5)

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

TextView tv = (TextView)findViewById(R.id.welcome);
tv.setText(getString(R.string.app_name) + getString(R.string.app_version));