开发者

android xml tag strings combine

开发者 https://www.devze.com 2023-03-28 17:01 出处:网络
how to connect two strings? <TextView android:text=\"@string/app_name.@string/app_version\" android:layout_height=\"wrap_content\" android:layout_width=\"fill_parent\"开发者_C百科 android:gravity=

how to connect two strings?

<TextView android:text="@string/app_name.@string/app_version" android:layout_height="wrap_content" android:layout_width="fill_parent"开发者_C百科 android:gravity="center" android:layout_alignParentLeft="true" android:id="@+id/Welcome" android:textSize="34px"></TextView>

android:text="@string/app_name.@string/app_version"

the emulator directly printed "@string/app_name.@string/app_version" instead of the string it supposed to be something like "APP 1.2"


you can't do that, if you want to use two strings in your TextView, you'd have to set the text programmatically:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号