How can I write "ó" in Android Studio on layout? - android

I am intented to write Iniciar sesión, but the ó not working. For this reason I changed to ó but is another error.
<TextView
android:id="#+id/textView"
android:layout_width="330dp"
android:layout_height="24dp"
android:text="Inicio de sesión"
tools:layout_editor_absoluteX="27dp"
tools:layout_editor_absoluteY="28dp" />
¿I must configure Android Studio?
I added compileOptions.encoding "ISO-8859-1" in build.gradle but the error persist.
Help me, please.
Thank you!

To fix this issue, you have to create a Strings.xml file and add to it and qualifier (Spanish language) then you can add this letter with accent without any problem
<resources> <!-- spanish language qualifier -->
<string name="test_text">Iniciar sesión </string>
</resources>
You can read more about qualifiers in the oficial documentation here:
Qualifiers

You should avoid to use text like this, directly on your layout file. Instead of it, you should relay on the file string.xml where you define all the texts your xml files will need to display. By doing this, you will be doing nothing less than the correct specification from Android makers in order to localize your app (more info on this: https://developer.android.com/guide/topics/resources/localization.html ).
So, proceed this way:
1) on your res folder there is another one called values. There you will find your strings.xml file. Open it and create a new key, let's call it txtarriba, like this:
<string name="txtarriba">Begin of session</string>
2) with android studio or your regular file manager, create another folder below your res folder, call it values-ES.
3) inside values-ES create a new file named strings.xml, there you will insert the translation of that key txtarriba. So do this:
<string name="txtarriba">Inicio de sesión</string>
4) Then, on your primitive layout xml file you define your textview like this:
<TextView
android:id="#+id/textView"
android:layout_width="330dp"
android:layout_height="24dp"
android:text="#string/txtarriba"
tools:layout_editor_absoluteX="27dp"
tools:layout_editor_absoluteY="28dp" />
DONE.
With this you can assure you app is, from now on, correctly showed according to your device idiom. If your device is in english, Begin of session will be showed. If device is set with spanish language, you will read Inicio de sesión. With this you can forget all the troubles about special chars, Android manages this for you ;)

Related

SharedPreference values form xml

I'm writing preferences page (preferences.xml), and trying to retrieve values from resources file. This code is working;
<PreferenceScreen ...
<ListPreference
android:entries="#array/tips"
android:entryValues="#array/tips"
android:title="Tip rate"
/>
But this is not;
<EditTextPreference
android:defaultValue="#integer/invoiceNumberNext" // this doesn't work
android:key="invoice_number_next"
android:title="Next Invoice #"
android:inputType="numberDecimal"
/>
I have this in my defaults.xml page which is under res/values
<resources>
<integer name="invoiceNumberNext">1001</integer>
</resources>
Any idea why I'm not able to fetch some values?
The problem is that you misplaced your value. If you reference a value with #integer it must be in a xml file called (what a mystery...) integer.xml. This file must be in the folder structure
res/values/integer.xml
So right click on values folder and click "New-->Values resource file" and then enter integer.xml Here, now add your resources like you have done....tataaaa....you can use it.
EDIT
As I hadn´t understand the original question correctly, I have to elaborate this answer. Of course it is possible to create a file defaults.xml and put an <integer> item inside, and this is still available by #integer. So, at the beginning of this question, it seems that you misplaced the file into the wrong directory. But that isn´t the case so your problem must be anywhere else. If the default.xml is in res/values, it should work.

How to solve this issue of Hardcoded string?

[I18N] Hardcoded string "Happy Birthday Debashish", should use #string resource less... (Ctrl+F1)
Hardcoding text attributes directly in layout files is bad for several
reasons: * When creating configuration variations (for example for landscape or
portrait)you have to repeat the actual text (and keep it up to date when
making changes) * The application cannot be translated to other languages by
just adding new translations for existing string resources. In Android Studio
and Eclipse there are quickfixes to automatically extract this hardcoded string
into a resource lookup.
Ths is not an error but a warning. As a general rule, you should never use hard-coded strings in your layout but always use string resources instead (which means that all the strings are stored in one separate file where they are easily changeable for different languages and so on).
To convert a hard-coded string into a string resource:
Put the curser on the hard coded string;
Press ALT + Enter;
Enter a name for your ressource;
Click OK.
After doing this the warning will be gone.
This is just a warning.
Define your string in string.xml file
Happy Birthday Debashish
and in textView use this string as
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/string_name"
/>
This is only a warning. The function will still work as intended. It is just recommended to place your text in the strings.xml file. This makes future changes much simpler and is easier to reference across multiple pages.
First, place the <string> element in values/strings.xml like this:
<string name="your_string_name">Happy Birthday Debashish</string>
Then, you can reference the string in the .xml file as follows:
<TextView
android:text="#strings/your_string_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Again, it is not required to do it in this method. It just makes things simpler to manage and change in the future if needed.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title"
tools:text="Happy Birthday Debashish" />
When you are in the 2019 version. Go to the strings.xml and Add this in to it
<string name="Your text">Your Text</string>
Or
In the warning it has the Fix button you can click it for fix

Hindi Text in Eclipse on Android

How can one directly input Hindi text into the eclipse IDE on android?
I would like to type Hindi text directly into the eclipse IDE without copy/pasting it from somewhere else, see this demo for an example of writing Hindi text quickly.
I would like to do the same thing in the eclipse IDE.
Use hindi texts inside String.xml file like
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hindiText"> पवन कुमार</string>
</resources>
And use this on your app's TextView
<TextView
android:id="#+id/textView"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hindiText"
android:textSize="28sp" />
Yes Hindi language can support in Android devices. You need to follow the steps.
Step 1:
Just create one values folder under resources like values-hi and add strings.xml file inside of this folder. You can add your translated strings in this strings.xml file.
example
<string name="your_text">अपका संदेशर</string>
Step 2:
If you call your strings from the other layout xml files then just call like the following
android:ext="#string/your_string"
Step 3:
You can also use string values in java code programmatically.
I think you are looking forward for multi-language(English AND Hindi) support for your application. If so,
strings.xml in values folder
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="welcome">accueil</string>
<string name="email">adresse e-mail</string>
<string name="password">mot de passe</string>
<string name="login">connexion</string>
<string name="signup">Ne pas avoir un compte? signer</string>
</resources>
strings.xml in values-hi folder
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="welcome">स्वागतम</string>
<string name="email">ईमेल पता</string>
<string name="password">पासवर्ड</string>
<string name="login">लॉगिन</string>
<string name="signup">खाता नहीं है? साइन अप करें</string>
</resources>
for more references please check this link
EDIT (as per the comment)
Try this
1.Windows > Preferences > General > Content Types, set UTF-8 as the default encoding for all content types.
2.Windows > Preferences > General > Workspace, set "Text file encoding" to "Other : UTF-8".
For more references, please check this
blog
Use UTF-8 encoding in android studio , below is setting page , using
utf-8 encoding will allow you to paste hindi fonts in xml and java
code.
For Eclipse IDE : below is path to configure the encoding :
Preferences > General > Workspace > Text file encoding
Today i found solution of my question.
i found that Google develop many inputtools for windows OS , Android
and for Web in many language that use for fastly type any language with the help of English typing.
So i download inputtools at URL : Download Page thank you Everyone for help me

Android application name error

I tried to build an android application, when I use non-english langues like persian as name of application it causes this error AndroidManifest.xml file missing and no manifest builds but when I use english it works successful, why?
at the top of every XML file in Android you'll see
<?xml version="1.0" encoding="utf-8"?>
So first I ask you: is persian included in utf-8 encoding?
I had a quick look on this link http://www.utf8-chartable.de/ and it seems to be me that's a no but I'm no language expert and that table might show persian as one of it related or base languages (like portuguese uses latin set)
If persian is not available in the utf-8 your best option to try to get this name in the app name is to create a strings_per.xml (inside the /values/ folder) and in there you put a different encoding and the string you need for the app name.
note that I tried to isolate the problematic variable in its own file because I'm not sure it would be a good idea to mix it with the rest of the manifest.
Farsi IS included in UTF8.
You need to add a string in strings.xml in /res/values.
Then define a farsi name there.
Your string.xml will look like this:
<string name="app_name">اسم اپ</string>
<string name="title_tab1">تماس با ما</string>
<string name="action_settings">Settings</string>
And you will reference it in you manifest.xml like this:
android:label="#string/app_name"
But remember: Farsi characters are not perfectly shown in android 2.2 and 2.3.
The characters are displayed separately. For later androids this is not an issue.

Internationalization of string.xml issue

In my application I do have several different string resources each per locale like:
res/values/string.xml //default
res/values-en/string.xml //english
res/values-it/string.xml //italian
Now the problem - each of files contains hundreds of keys and from time to time I can't really define which language is lacking some keys. Say:
<string name="yes">Yes</string> <!-- Default -->
<string name="yes">Yes</string> <!-- English -->
<string name="yes">Si</string> <!-- Italian -->
And if in German string.xml there'll be no "yes" key corresponding value will be default "Yes" instead of German "Ja" - which is disaster.
Help me to find a way to define lacking string resource keys.
You can also try MOTODEV Studio. You can use it a standalone IDE (based on Eclipse) or as an Eclipse Plugin. What you would like is an editor, which includes, that makes really easy working with localizable strings. It will show you in a same view all the files as columns, so you will not need to do any merge or diff whatsoever.
Use http://winmerge.org/
You can compare files easily.
copy all the files to one text file,, Sort the file and then check one key at once,, loooong method but the most effective one

Categories

Resources