Can l add same sting to string in resources like it's?
<string name="text_base">Same text</string>
<string name="text_base_my_text">#string/text_base + and new text</string>
Can l get string in text_base_my_text "Same text and new text"?
yes you can <string name="Hor">#string/Cli</string> <string name="Cli">HOLA</string> in string.xml
and you can see "HOLA" when you refer #string/Hor
if you a literal inside android understand that all is a literal. i mean:
<string name="text_base">Same</string>
<string name="other">#string/text_base + new text </string>
you will see #string/text_base + new text when you refer to #string/other
but if you put:
<string name="text_base">Same</string>
<string name="other">#string/text_base</string>
when you refer to #string/other you will see Same
Related
I have been struggling to understand how to change the font family of the values/Strings.xml directory. Is there an easy way to change the font? I have added my desired font to the assets folder, but my titles are in the Strings.xml inside the values directory like this:
<resources>
<string name="app_name">FarrApp</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="title_activity_search_result">Search results</string>
<string name="title_activity_login">MyApp</string>
<string name="title_activity_Calendar">Calendar</string>
<string name="title_vision">Find local events near you</string>
<!-- Strings related to login -->
<string name="prompt_email">Email</string>
<string name="prompt_password">Keyword</string>
<string name="action_sign_in">Register</string>
<string name="action_sign_in_short">Sign in</string>
<string name="action_forgot_password">Forgot password?</string>
<string name="action_forgot_submit">Reset password</string>
<string name="error_invalid_email">This email address is invalid</string>
<string name="error_invalid_password">This password is too short</string>
<string name="error_incorrect_password">This password is incorrect</string>
<string name="error_field_required">This field is required</string>
<string name="permission_rationale">"Contacts permissions are needed for providing email
completions."
</string>
I am not really good at designing my app and do not have too much experience with design layouts. Any help will be greatly appreciated.
You will need to reference the font in your code, then apply it to your views:
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/DroidSans.ttf");
TextView tv = (TextView) findViewById(R.id.textView);
tv.setTypeface(tf);
Or you can do it from the xml with the attribute android:typeface.
I need to know if there is a way to get String type data from strings.xml (nested in resource tag)
<resources>
<string name="app_name">One World</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="productInfo_lanIP">LAN IP Address :\t</string>
</resources>
and I need to get productInfo_lanIP from this and use it in my MainActivity.java to perform insertion of another string into this one.
Note: I am updating the value so I can use it to display it just after through an XML page. And I am using Android 4.2.2
you can get the strings like:
String productInfo_lanIP = getString(R.string.productInfo_lanIP);
go through this link
String mystring = getResources().getString(R.string.productInfo_lanIP);
Accept the answer if it helped you :)
In strings.xml
Lets say I have the following strings:
<string name="CourseInfo">Course Information</string>
<string name="CourseInfo1">Course Information:</string>
<string name="CourseInfo2">Course Information:-</string>
As you can see the string is the same, the only difference is that the second one has a colon and the third one has a colon and a dash.
Is this the most optimal way to do this? It seems kinda repetitive to do it this way.
maybe you can use some thing like
<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>
see http://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling
so for your example
<string name="CourseInfo2">Course Information%1$s</string>
and then
Resources res = getResources();
String text = String.format(res.getString(R.string.CourseInfo2), ":");
String text2 = String.format(res.getString(R.string.CourseInfo2), ":-");
I am doing a project, it is going to finish but I am facing a problem to release the project. Right now, the context of the project is in English. But the requirement is like, according to the country location the context will be changed e.g Japanese, Spanish, Chinese etc. So my concern question is how to do that?
Foe English I have written like:
<string name="bookedittext">EDIT</string>
<string name="button_delete">Delete</string>
<string name="button_delete_cancel">Cancel</string>
<string name="button_back">Back</string>
<string name="progress_deleting">Deleting...</string>
<string name="share_message_conf_delete">Do you want to delete?</string>
<string name="share_message_conf_delete_all">Do you want to delete all?</string>
<string name="TEXT_SHARE_VIA">Share Via</string>
<string name="TEXT_CONTENT">Image content</string>
<string name="TEXT_SELECT_APPLICATION">Select an Application</string>
<string name="TEXT_MORE_OPTIONS">More Options</string>
<string name="TEXT_FACEBOOK">Facebook</string>
<string name="TEXT_KAKAO_TALK">Kakao Talk</string>
<string name="TEXT_SKYPE">Skype</string>
<string name="TEXT_KIK">Kik Messanger</string>
<string name="TEXT_FRING">Fring Messenger</string>
<string name="TEXT_TWITTER">Twitter</string>
<string name="TEXT_YAHOO">Yahoo Messenger</string>
<string name="TEXT_USE_FOR_DEFAULT">Use this by default action</string>
<string name="TEXT_USE_FOR_BACK">Back</string>
Please help me how to convert these to Japanese?
You can have multiple resouce files, for different locales.
Read
http://developer.android.com/guide/topics/resources/localization.html
and
http://developer.android.com/reference/java/util/Locale.html.
i am translating some text into Italian, an i got an error on this line of the XML of the strings.xml because the ' symbol on L'utente:
<string name="usernotexist">L'utente non esiste</string>
how to solve that error?
<string name="good_example">"This'll work"</string>
<string name="good_example_2">This\'ll also work</string>
Taken from the official documentation: http://developer.android.com/guide/topics/resources/string-resource.html
Try this
<string name="dialog">L\'tutente non esiste </string>