From there follow along with each tutorial lesson and learn this tutorial - AndroidIdentifiers. You
can also create; RUN your apps from the coded pages in these tutorials using Android Studio. Android Studio is for desktop computers. Choose Java XML as the programming language.
Android Studio is free to install and use. Complete Example Codes are available for each of our tutorials. With these example codes you can make a functioning android app in
either AIDE or Android Studio.
Each interactive type tutorial shows you how to create your app for the tutorial code topic: and has coding examples, photos, copy and paste code, making it easy to learn android programming (java, xml).
AIDE and ANDROID STUDIO
We are using AIDE, to create these tutorial apps on our tablet with android version 4.2.2; using the Java XML programming language.
We are using the AIDE coding editor to code our pages; and then to Create - RUN our apps. AIDE is a SDK coding environment for android devices like a tablet or smartphone. AIDE has a free and paid version. The paid version is required if you want to create apps and then publish then to the marketplaces like Google. As of Sept 2017, the paid version of AIDE is about $20 canadian.
For this tutorial, we are going to learn about resource ids, known as resource identifier, R.id, and how they are used in the layout file main.xml
We are going to create a new app for this tutorial, and name is - AndroidIdentifiers
You can also create; RUN your apps from the coded pages in these tutorials using Android Studio. Android Studio is for desktop computers. Choose Java XML as the programming language. Android Studio is free to install and use.
Complete Example Codes are available for each of our tutorials. With these example codes you can make a functioning android app in
either AIDE or Android Studio.
To open your other app files do the following:
Click FILES, from top right dropdown selection: (all files now show on left side menu) then on left side menu; goto res/ for layout files and strings.xml, and drawable folders.
To goback to previous FOLDERS, just click 'orange folder', as shown here, it returns to previous.
To open androidmanfest.xml file, click on App name AndroidIdentifiers, look to bottom of file hierachy; to see androidmanifest.xml file,
just click to OPEN it in AIDE editor.
Just double click a file to open it in the coding editor. Once file is opened they also show as tabs at top of editor.
To CLOSE A PROJECT; Your app, from right side menu dropdown, choose, MORE, then Close Project. To OPEN a file, just choose App Project name from left side menu.
Code the Strings.xml
We will add one line of text that reads:
"Learn To Use Resource Identifiers in Code". We will name our string, learnidentifiers, and type the text as shown.
Our strings.xml file also has another string, our: app_name,AndroidIdentifiers, which we will leave in the strings.xml as this is the name that shows at top of view, next to the little green android icon. It is created for you when you created your app using the simple java/xml template app.
Once the text is added to the strings.xml file, SAVE the file.
Using android:id Resource Identifier
How And Why To Use Them
It is common in android java xml coding, to use resource ids. They are used for textView elements, button elements, imageview elements; xml layouts, and other user interface components. The id is a 'resource identifier', meaning it lets the android system know where that resource is located and enables the system to get info from it if it needs to.
This is important when we want to manipulate code(make something happen) from the code in our xml file elements.
For example: i added a Button to my layout file at main.xml, using the Button element. I want that button to be clickable. How do I make it clickable.
In order to make the button clickable we first need to have a way to find that button; we do this by using the id. resource identifier. To add the resource we use the attribute;
'android:id ="namegoeshere', and it is coded in your element, doesn't matter which line it is at; can name it as you like.
If your adding the resource identifier for the first time, (new one), then use this; android:id="@+id/text1", The +, symbol indicates that this is new
resource ID, and the aapt tool creates a new resource integer in the R.java.class.
text1 is the name i gave it, you can name it anything you want to.
The android:id="@+id/text1, name is now a resource ID attached to this element. You can then refer to the TextView to which the ID is associated in your Java coded page as shown -using the findViewById property.
The first java coded page in your app is usually named: MainActivity.java. The first xml page of your app is usually named: main.xml
If you use a template from AIDE to create your app like the Hello World Java XML app the pages will be named as such.
Each additional pages you create can be named whatever you like. The file extensions are created automatically for you when you create the page name. Example: you want to create a new xml page named: learnbuttons.xml; then you click create new xml page in the res folder and just type the name `learnbuttons`, AIDE editor usually adds the xml extension to the file for you. If it doesn't just add the xml yourself.
Same process if you need to add additional java class pages to the app your making. Java files are found in the src folder of your app project; and xml files are found in the res layout folder of your app project.
You can add resource ids to your elements even if your not going to use them in your java page right away. It is good coding practice to add them, that way,if you do decide to write code to add controls to them, the resource id are already coded.
Example of adding a control to a resource id would be: adding a resource id to a Button element, and then making that Button clickable in order to do something.
You can get the code from this tutorial from our EXAMPLE CODE section on this page. You can add the code easily to your apps coded pages using copy/paste. Just delete the code that's in your main.xml, mainactivity.java, and strings.xml files and replace it with the code from this tutorial. Save each page after pasting the code.
And, if you practice adding additonal buttons
you can easily code them yourself. SAVE each page after editing.
Once a file is in the editor, you can edit, save it, then RUN your APP, Install,
and Open your app.
Make sure you SAVED EACH PAGE, before you RUN your code. SAVE, RUN, INSTALL, OPEN, your AndroidIdentifiers App. Once it has been installed on your tablet, you can open it Simply by Clicking on the Android little green App Icon,with the wording 'AndroidIdentifiers' on your tablet. It will be with your other installed apps.
If you make further changes to this App, you need to SAVE, RUN, UPDATE, INSTALL, OPEN the app.
This free script provided by