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
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.
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.
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.
This free script provided by
JavaScript
Kit