I am using takephoto_library for selecting multiple images.
https://github.com/crazycodeboy/TakePhoto
It is working properly but as you can see in the below screenshot, the caption is in Chinese.
I found that the view control is "com.darsh.multipleimageselect.activities" and Id of this caption is in the below
actionBar.setTitle(R.string.album_view);
Is there any way to change this string to English?
Is there any way to change this string to English?
Yes, you can change all the Strings in strings.xml
https://github.com/crazycodeboy/TakePhoto/blob/master/takephoto_library/src/main/res/values/strings.xml
Change these two chinese word to english
<string name="add">确定</string>
<string name="selected">已选</string>
In English
<string name="add">confirm</string>
<string name="selected">selected</string>
Try this .
find the strings.xml(values) and strings.xml(values-en) in the library of TakePhoto .
And change the string name to the English .
In the strings.xml(values)
string name="add">确定</string>
<string name="selected">已选</string>
<string name="limit_exceeded">最多能选 %d 张</string>
And add this to the strings.xml(values-en)
string name="add">confirm</string>
<string name="selected">selected</string>
<string name="limit_exceeded">You can choose%d at most</string>
And you can change this strings.xml(values-en) and strings.xml(values)
For internationalization, android looks in different directories for the appropriate local as determined by your selection for the phone. For instance, you should see something like this:
./explorer/src/main/res/values-uk/strings.xml
./explorer/src/main/res/values-tr/strings.xml
./explorer/src/main/res/values-ru/strings.xml
./explorer/src/main/res/values-pl/strings.xml
./explorer/src/main/res/values-de/strings.xml
./explorer/src/main/res/values-ko/strings.xml
./explorer/src/main/res/values-sv/strings.xml
...
Where the translated strings are in the values-../strings as determined by the res/values/strings.xml.
In my case, res/values/strings.xml has an entry:
<string name="createnewfolder">Create new folder</string>
which is translated in values-uk/strings.xml as
<string name="createnewfolder">Нова папка</string>
You might find Localizing with Resources useful.
I have the following unicode character that I want to use in a string: 🚕
I have found its hex and decimal code through this:
While I know how to use the "&" symbol in a string in strings.xml by doing this:
<string name="Example">Example character &</string>
I cannot use the car symbol.
How can I use this unicode character in a string in strings.xml?
Update One:
Following the first solution of using this: 🚗
I got the following error:ERROR IN APPLICATION: input is not valid Modified UTF-8:
It's
<string name="Example">Example character \u0026</string>
See more unicode characters here:
http://www.utf8-chartable.de/unicode-utf8-table.pl?number=1024&utf8=0x
if you go Unicode site : https://unicode-table.com/en/#control-character and click at this Unicode that says U+00AE you mustn't write the + symbol if you want copy paste this example at strings.xml
:) :) :)
<string name="example">"\u00AE"</string>
Few important Unicode symbols for android strings.xml
<string name=”Rs”>\u20B9</string>
<string name=”filled_bullet”>\u25CF</string>
<string name=”linear_bullet”>\u25CB</string>
<string name=”rect_bullet”>\u25A0</string>
<string name=”blank_rect”>\u25A1</string>
<string name=”true_tick”>\u2713</string>
<string name=”star”>\u2605</string>
Full link is here
<string name="ic_happy_font"></string>
or
<string name="edit">🚕</string>
Check that the XML is in UTF-8 and has <?xml ... encoding="UTF-8"?> or defaulted <?xml ... ?>.
First the Unicode code point is U+1F695 which is decimally 128661 (not ...3).
In XML content your approach is basically correct.
🚕
🚕
The error mentions "modified" UTF-8. This just means the code point U+0000, a binary 0, is also encoded as multi-byte sequence of bytes with high bit set. This is support for C where a "string" ends on a NUL byte.
As the TAXI code point needs 4 UTF-8 bytes, it might be that the XML on Android only supports less long UTF-8 sequences. At least for numeric entities &#...;.
If the entities are a problem, use an UTF-8 capable editor and paste the TAXI from the clipboard.
You might try whether there is a work-around, whether u-escaped chars are read (probably not):
\uD83D\uDE95
A last wild attempt would be to use
<?xml version="1.1" ...
I think the code point you have in your example is an ellipsis. As per this page, try
🚗
If anyone gets underlined space although you didn't intent it, you can avoid this by using unicode code point of space
For example:
<string name="conditions">By signing in you agree to our <u>Terms &
Conditions.</u></string>
would also underline space before 'Terms & Conditions'
solution:
<string name="conditions">By signing in you agree to our\u0020<u>Terms &
Conditions.</u></string>
I am using WebView to display the String resource. Here is the code-
<string name="abc">à</string>
<string name="abcd">è</string>
When i load this in my webView it displays some garbage values. How to display this special characters in a WebView??
Check this list of special characters and how to encode in html.
<string name="abc">à</string>
<string name="abc">è</string>
If you enter these values into your values XML file using the graphical interface, the IDE will automatically format them for you.
Put symbol code in string tag:
<string name="welcome">Welcome !</string>
Output will be look like:
Welcome !
For more symbol code use below link :
http://www.degraeve.com/reference/specialcharacters.php
Enjoy...
I am trying to make #sancorporation in my android application. I have written strings in string.xml e.g "<"string name="cor_name">sancorporation"<"/string>, but I need something like this "<"string name="cor_name">#sancorporation"<"/string>. How to take special symbol in android?
Use ascii value of # symble is 0040 so try it
for #sancorporation
<string name="mytest">#sancorporation</string>
or
<string name="mytest">\u0040 sancorporation</string>
Maybe this will help
<string name="specialChar"> "#" </string>
You can also try this
<string name="specialChar"> \# </string>
Edit:
Now I notice that you want to write #sanCorporation.
so you can use this in string.xml file:
<string name="corp"> "#sanCorp" </string>
I have to concatenate these two strings from my resource/value files:
<string name="Toast_Memory_GameWon_part1">you found ALL PAIRS ! on </string>
<string name="Toast_Memory_GameWon_part2"> flips !</string>
I do it this way :
String message_all_pairs_found = getString(R.string.Toast_Memory_GameWon_part1)+total_flips+getString(R.string.Toast_Memory_GameWon_part2);
Toast.makeText(this, message_all_pairs_found, 1000).show();
But the spaces at the end of the first string and at the beginning of the second string
have disappeared (when the Toast is shown) ...
What should I do ?
I guess the answer is somewhere here in this documentation link
or is it something like using & ; for the "&" character ??
Even if you use string formatting, sometimes you still need white spaces at the beginning or the end of your string. For these cases, neither escaping with \, nor xml:space attribute helps. You must use HTML entity for a whitespace.
Use for non-breakable whitespace.
Use for regular space.
I ran into the same issue. I wanted to leave a blank at the end of a resource string representing an on-screen field name.
I found a solution on this issue report : https://github.com/iBotPeaches/Apktool/issues/124
This is the same idea that Duessi suggests. Insert \u0020 directly in the XML for a blank you would like to preserve.
Example :
<string name="your_id">Score :\u0020</string>
The replacement is done at build time, therefore it will not affect the performance of your game.
This documentation suggests quoting will work:
<string name="my_str_spaces">" Before and after? "</string>
I just use the UTF code for space "\u0020" in the strings.xml file.
<string name="some_string">\u0020The name of my string.\u0020\u0020</string>
works great. (Android loves UTF codes)
This question may be old, but as of now the easiest way to do it is to add quotation marks.
For example:
<string name="Toast_Memory_GameWon_part1">"you found ALL PAIRS ! on "</string>
<string name="Toast_Memory_GameWon_part2">" flips !"</string>
There is possible to space with different widths:
<string name="space_demo">| | | ||</string>
| SPACE | THIN SPACE | HAIR SPACE | no space |
Visualisation:
use "" with the string resource value.
Example :
<string>"value with spaces"</string>
OR
use \u0020 code for spaces.
If you really want to do it the way you were doing then I think you have to tell it that the whitespace is relevant by escaping it:
<string name="Toast_Memory_GameWon_part1">you found ALL PAIRS ! on\ </string>
<string name="Toast_Memory_GameWon_part2">\ flips !</string>
However, I'd use string formatting for this. Something like the following:
<string name="Toast_Memory_GameWon">you found ALL PAIRS ! on %d flips !</string>
then
String message_all_pairs_found = String.format(getString(R.string.Toast_Memory_GameWon), total_flips);
Working well
I'm using \u0020
<string name="hi"> Hi \u0020 </string>
<string name="ten"> \u0020 out of 10 </string>
<string name="youHaveScored">\u0020 you have Scored \u0020</string>
Java file
String finalScore = getString(R.string.hi) +name+ getString(R.string.youHaveScored)+score+ getString(R.string.ten);
Toast.makeText(getApplicationContext(),finalScore,Toast.LENGTH_LONG).show();
Screenshot
here Image of Showing Working of this code
All answers here did not work for me. Instead, to add a space at the end of a string in XML i did this
<string name="more_store">more store<b> </b> </string>
An argument can be made for adding the space programmatically. Since these cases will be often used in concatenations, I decided to stop the madness and just do the old + " " +. These will make sense in most European languages, I would gather.
I've no idea about Android in particular, but this looks like the usual XML whitespace handling - leading and trailing whitespace within an element is generally considered insignificant and removed. Try xml:space:
<string name="Toast_Memory_GameWon_part1" xml:space="preserve">you found ALL PAIRS ! on </string>
<string name="Toast_Memory_GameWon_part2" xml:space="preserve"> flips !</string>
This may not actually answer the question (How to keep whitespaces in XML) but it may solve the underlying problem more gracefully.
Instead of relying only on the XML resources, concatenate using format strings.
So first remove the whitespaces
<string name="Toast_Memory_GameWon_part1">you found ALL PAIRS ! on</string>
<string name="Toast_Memory_GameWon_part2">flips !</string>
And then build your string differently:
String message_all_pairs_found =
String.format(Locale.getDefault(),
"%s %d %s",
getString(R.string.Toast_Memory_GameWon_part1),
total_flips,
getString(R.string.Toast_Memory_GameWon_part2);
Toast.makeText(this, message_all_pairs_found, 1000).show();
There is also the solution of using CDATA. Example:
<string name="test"><![CDATA[Hello world]]></string>
But in general I think \u0020 is good enough.
If you need the space for the purpose of later concatenating it with other strings, then you can use the string formatting approach of adding arguments to your string definition:
<string name="error_">Error: %s</string>
Then for format the string (eg if you have an error returned by the server, otherwise use getString(R.string.string_resource_example)):
String message = context.getString(R.string.error_, "Server error message here")
Which results in:
Error: Server error message here
It does not work with xml:space="preserve"
so I did it the quickest way =>
I simply added a +" "+ where I needed it ...
String message_all_pairs_found = getString(R.string.Toast_Memory_GameWon_part1)+" "+total_flips+" "+getString(R.string.Toast_Memory_GameWon_part2);