I want to translate these Strings of my Java Class:
String s = getResources().getString(R.string.shipping_date, shipping_date.toString());
loaddate.setText(Html.fromHtml(s));
String t = getResources().getString(R.string.shipping_time, shipping_time.toString());
loaddate.setText(Html.fromHtml(t));
String u = getResources().getString(R.string.shipping_address_c, shipping_address_address.toString());
loaddate.setText(Html.fromHtml(u));
String v = getResources().getString(R.string.transport_description_c, description.toString());
loaddate.setText(Html.fromHtml(v));
String w = getResources().getString(R.string.weight, weight.toString());
loaddate.setText(Html.fromHtml(w));
String x = getResources().getString(R.string.destination_date, shipping_date.toString());
loaddate.setText(Html.fromHtml(x));
String z = getResources().getString(R.string.destination_address, shipping_date.toString());
loaddate.setText(Html.fromHtml(z));
my string.xml file is this:
<string name="shipping_date">"<b>1it: </b> %1$s"</string>
<string name="shipping_time">"<b>2it: </b> %1$s"</string>
<string name="shipping_address_c">"<b>3it: </b> %1$s"</string>
<string name="transport_description_c">"<b>4it: </b> %1$s"</string>
<string name="weight">"<b>5it: </b> %1$s"</string>
<string name="destination_date">"<b>6it: </b> %1$s"</string>
<string name="destination_address">"<b>7it: </b> %1$s"</string>
But I get only one of them on my app:
Could someone please help me?
You're overwriting the last text set by repeatedly calling loaddate.setText()
. Instead concat them into one string and call loaddate.setText()
once like this:
String s = getResources().getString(R.string.shipping_date, shipping_date.toString());
String t = getResources().getString(R.string.shipping_time, shipping_time.toString());
String u = getResources().getString(R.string.shipping_address_c, shipping_address_address.toString());
String v = getResources().getString(R.string.transport_description_c, description.toString());
String w = getResources().getString(R.string.weight, weight.toString());
String x = getResources().getString(R.string.destination_date, shipping_date.toString());
String z = getResources().getString(R.string.destination_address, shipping_date.toString());
loaddate.setText(Html.fromHtml(s + t + u + v + w + x + z));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.