Develop Android Apps, Tutorial strings.xml
NEXT Page - Android App Coding - res/drawables Tutorial
PREV Page

Goto - All Tutorials

Resources Values Strings.xml Tutorial

res/values/strings.xml
To locate this file in your android app project files goto:
AppProject/nameOfApp/res/values/strings.xml
nameOfApp is the name you gave the app when creating the AppProject

When you create a simple pre made template in AIDE, these files are created for you. Each app you create must have at least 1 activity, and within that activity there is a text view. Within this text view is where you place the name of the string (the text) you want shown in your app. You can name the string whatever you want. (essentially a text view is like a web page view, although a text view is a tablet screen size not a computer screen size)

These strings are coded, then placed in a file called "strings.xml". The strings.xml file is at folder res/values/strings.xml
When you Run and build your app android looks to the res/strings.xml folder and matches the string name to the page (activity) where that string name is located (in the textview code). The text then gets shown in that activity.

You can have as many strings as you want for whatever you want; from titles, words, paragraph headings, photo descriptions; basically whatever your app is about and the text required for it.

If your app has more than one activity (one page) then each additional page needs a text view, and that text view would also need strings.xml to add text to the page. If your app didn't have any text on any page then you would not need to create strings.

res/values/strings.xml Res Values Strings xml Tutorial Android Apps

Looking at strings.xml image; we see there is s string named
androidTutorialsIntro and that the wording/text for that string is Learn Android For Beginners

There is also a string named
app_name and the wording/text for that string is
Learn To create Android Apps- AndroidAppCoding.com.

Looking at this next image: androidmanifest.xml
We see the android label has a string named 'app_name'. This is the name you give your app and it will show at the top left of your screen next to the app's icon. To code it we must place the 'text' we want shown into the strings file as shown in the previous image.

The app_name is also shown in the androidmanifest.xml file; in the application and activity elements; as shown in this image.

androidmanifest.xml



The main.xml is a file that has the textView particulars, the attributes for each coded property. Example, you may want the text to be centered in the textView, to be a certain size, bold or not bold, italic or not, text color; all of these are coded in the 'textview' element of the main.xml file for each property you add as shown in this image.

You can have as many 'textviews' as you want for each app activity (app screen page). Each 'textview' can have a string. Each 'textview' can have specific attributes for text; one textview may be the page title, another could be paragraph header, another the paragraph itself. Yet another could be the textview defining the text above an image you added.

By adding the 'textview' you can change the look of the text you add in each area of your app activity.

Res Layout Main xml Tutorial Android Apps
Let's look at the particulars of the code in the 'TextView', of this image. We see the textview properties and their attributes: the text is to be wrapped, the text should be 10dp from the top of the TextView, the text size is 25dp, the typeface is "sans", the text color is #46C646 (green), the text color link is #eeefff .

And, any domain names should automatically be hperlinked; autoLink=web example; if androidappcoding.com is placed in the text view string, not only will it show as text, but it will be clickable also.

android:text="@string/mathintro", means there is some Text to be placed in the screen view for this activity. To see what is text is; you would goto the strings.xml file and look for mathintro, which you can see by looking at this image is - PreAlgebra Learn Equations.
string Math Intro, android apps

Your Android App will be updated with the newest text you add or edit - just makes changes to the strings.xml file and then RUN your app.


Share This Page

AIDE for creating Android Apps on your tablet or cell phone(android).
Free and Paid.
GoTo Aide

ANDROID STUDIO - for creating Android Apps on your desktop computer.
Free to Install and Use
Learn more - Android Studio

The Java XML files we code(example tutorial codes) and the Android Apps we create in our Free Tutorials are compatible with Android Studio and AIDE. Just choose Java XML as your Programming Language.


The Google Play Store has many Free Apps for learning to code Android.

Do A Google Play Search
"Learn Android, Android Programming, Android Development,Learn Java XML "



You May Like:
Make Sushi Rolls Taste World Wines Flavours and Aromas
To Copy Code Use Mouse

This free script provided by
JavaScript Kit