How To- Code a Style Definition Android Tutorial '
Prev Page How To Code a Text Toast Message This Page Coding Android Resource Identifiers

Next, Tutorials III Coding Shape Drawables - Lines


If you are just arriving at this page; and you are not familiar with with creating Android Apps, we suggest you begin with our tutorials: Coding Android App Pages and How To Create a Simple App in Android

From there follow along with each tutorial lesson and learn this tutorial - AndroidIdentifiers.

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.

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.

Learning To Code Java Pages

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




Where Code is Coded

This app will also have some text added(wording) so we will add a TextView element and add to our strings.xml file, for the text we add.
All string names are coded in the strings.xml file at res/values of the AppProject/AndroidIdentifiers, and reference to the string name is made in the TextView element.

We will add a simple button gallery to our main.xml layout page, at AppProjects/AndroidIdentifiers/res/layout/main.xml

We will be adding some code to our java page, which is mainactivity.java which is at AppProjects/AndroidIdentifiers/src/com/acw/learnidentifiers/mainactivity.java

Creating Our New App
Create a Android app, choose java xml programming language

Open AIDE, Select New Project, from the left menu, or center menu hierachy of files; and do the following:

Choose HELLO WORLD example app template(java/xml);
For app name; type AndroidIdentifiers

For app package name type: com.acw.learnidentifiers

Click Create


Now your new app has been created with the name 'AndroididIdentifiers'.

This name will show on the left menu hierachy in AppProjects within AIDE.
The main.xml, and mainactivity.xml pages of your app are opened in AIDE for you. Just click the top tab to toggle them.


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.

opening files AIDE

To goback to previous FOLDERS, just click 'orange folder', as shown here, it returns to previous.
view files in coding editor AIDE


To open androidmanfest.xml file, click on App name AndroidIdentifiers, look to bottom of file hierachy; to see androidmanifest.xml file,
open manifest file in AIDE
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.
android:id="@+id/namegoeshere

findViewById(R.id.text1);

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.

Button Gallery
app coding a button gallery for app resources id
For this tutorial we are going to create a simple button gallery app by coding our main.xml layout file. The coded elements for each button will have a resource id attached. This will show you how ids are added for elements and how they can be named.

You can code additional buttons if you like; this is good practice for coding the resource id. To get more Button attributes you can review our previous tutorial on Buttons Typesand, how to place Buttons within your View.

COPY/PASTE CODE

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. .


and Reading on android:id value, and Accessing Resources in Code
Coding Resources android:id in layout file How Tos - Accessing Resources


EXAMPLE CODE - Code For This Tutorial

JUST USE YOUR MOUSE to copy the code for this tutorial App Name is 'AndroidIdentifiers - located at AppProjects/AndroidIdentifiers in AIDE, open the AIDE app, then open App Projects, THEN select the 'AndroidIdentifiers', app from your files hierachy(left menu); then click on any file from the app, like strings.xml Make sure at top of page, the app name 'AndroididIdentifiers' is there next to AppProjects like so: AppProjects/AndroidIdentifiers, then you know you have the proper App.

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.





Example Code:
Use Mouse To Copy Paste the Code




This free script provided by
JavaScript Kit

Share This Page


AIDE for creating Android Apps on your tablet or cell phone(android).
Free and Paid - with Free create android Java/xml template apps and couple free android lessons. With paid some lessons included, create android Java/xml template apps; and create a keystore for your app. With a keystore you can publish your app at markets like Google.
GoTo Aide

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

The Java XML files we code(example 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.


You May Like:
Make Sushi Rolls Taste World Wines Flavours and Aromas

TUTORIALS I
Java XML
The Coded Pages

Beginners Article
About Our Tutorials
Coding androidmanifest.xml
Coding R.java
Coding buildconfig.java
Coding mainactivity.java
Coding main.xml
Coding strings.xml
Coding drawables

TUTORIALS II
Java XML
Learning To Code

Create A Simple
Android App

Change App Icon

Add Text and Style

Add Buttons To App

Placing Text in
Buttons


Change View
Background Color


Change Screen
Orientation


Add Image to
Activity View


Add Horizontal
Scroll View


Add a Frame Layout

How to Add Themes
To Your App

How To Code
Customized Styles

Code a Toast Message

Coding Resource
Identifiers



from the Web
SPECIFIC CODING TASKS

Add Clickable Button
To textView

Image Button with
Selector

Linear Layout with
weight attribute

OnClick Displays
Message

Screen Density
Coding Practices


CODING ENVIRONMENTS

AIDE
for android tablets

Android Studio
For desktop computers


IMAGES ICONS FOR YOUR APPS

Code Canyon Paid From $1

IconFinder.com Free and Paid From $1


Our ARTICLES

App Distribution
Launching Your Android App
How To Be Successful

Android App Libraries
What are they and how
to implement them


ScrollView
How To Implement
ScrollView


View All Articles


Coding Tools

Android Studio
Course - Paid

Java Programming
Course - Free

Git Hub Course
Free



About Our Images

All images on this page are copyrighted material.
You can use the images included with each tutorial for the purpose of creating your android app. These images are not to be distributed or sold.

APP SIGNING KEY- GOOGLE


How To Add Your Google Key
To Manifest.xml
Web Article

How To Sign Your APK Web Article

Google Developer Console
Create Account Submit Your App
Web Article


APP SIGNING - AMAZON
Amazon App DRM - APK KEY
Amazon Developer Portal
Create Account - Submit Your App


MONETIZE YOUR APP
InMobi
AdMob
Google's In-App Billing for App monetization.

Monetizing Your App
How Tos




Follow Us On Twitter
Tweets by @codeandroidapps