Android Development by Netero #2 05-13-2014, 01:23 PM
#1
In this tutorial you will Set up Your first project & Creating your first Android Application.
With the tools & SDK downloaded and installed, "if you didn't already install the SDK files & the tools necessary read This",
we will begin by creating the classical Hello World! application
so lets get started.
A note before we begin, I don't explain somethings because it will confuse you since you are a starter on Android Development ,
follow my future tutorials and you will be able to understand things that you currently don't understand/ I didn't explain in future Tutorials.
Part One : Setting up Project
Using Eclipse create a new project by selecting File->New->Android Application Project (see figures below)
![[Image: nifdJMX.png]](http://i.imgur.com/nifdJMX.png)
Then you will get a window like the figure below.
![[Image: 2bWKg3f.png]](http://i.imgur.com/2bWKg3f.png)
Application Name:It's the name of the application on the Android phone.
Project Name:As the name says its the name of the project, basically this name is used for you "The Developer" to identify your project later when/if you want to modify.
Package Name:Applications are made up of many packages , they contain codes you define,maybe you are working with a team
and each one of you are responsible for a package (ie. codes).Usually the name of the main package is the reverse domain
"example com.hackacademy" you can chose any name you like, but the reverse domain name is general.
The codes that we write are called source code, like many programming languages Java is a compiled language,
meaning it needs another program called compiler to translate the codes from source code
"readable codes by human" to machine code "codes understandable by computer made of 0 and 1".
Minimum SDK required:Is the minimum android version that can run our program.
As stated in first tutorial each version have its own characteristics , programs that are written for Higher versions
cannot run on the low versions, that's the basic idea.So when we choose the minimum SDK we are saying that the
minimum version that can run the code is (in this example its Froyo).Some features are made
for specific versions and following versions we must know if the minimum version that we are coding for
supports our code or not "More about this in later tutorial".
Target SDK:The Android version that we want are specifically coding for. (sorry if I couldn't explain this well).
Compile With:The compiler program that we use to change the source code to machine code, almost all the time you will compile with the same version as Target SDK.
Theme:This is the base theme used in our application. "More about this in later tutorial"
Then click next, and you will get the following window.
![[Image: 4G7TfgL.png]](http://i.imgur.com/4G7TfgL.png)
Create custom launch icon This will allow you to create your own Icon "more on this in next image".
The other parts I will talk briefly, but usually you will leave it as it is for the applications that you will develop.
Start activity basically this means to create a GUI window.
Mark this as a Library Our applications are mostly a mixture of these codes, codes that have been developed
by Google or other developers, these codes are ready to be used. "More about this in later tutorial".
Click Next then following window will come.
![[Image: JNuCFVk.png]](http://i.imgur.com/JNuCFVk.png)
You can create a custom application image/icon in here, I prefer if you play with this one and experiment to what the different options give you.
Click Next , start Blank activity then click Next.
And you will get this window
![[Image: woW6Voh.png]](http://i.imgur.com/woW6Voh.png)
Activity Main is the name of the Main class, the class where the application starts.
Layout Name the graphical layout "GUI" that the program will load when program starts.
Fragment Layout "More about this in later tutorial"
Navigation Type the type of navigation which your application supports, ie. Navigation Drawer ,Action bar tab...etc "More about this in later tutorial"
Then click Finish
Now we finished setting up our first project
Lets write a few codes
but before that do the following final steps.
Part Two : Writing our First Program
If the IDE (Eclipse) didn't open the two files fragment_main.xml & MainActivity.java (if you didn't the names 2 steps before now).
In the package explorer, expand your project and expand the res folder then open the fragment_main.xml.
.xml Files define the user interface of your application.The default view is "Linear Layout".
To modify the fragment_main by hand click on the fragment_main.xml located in the bottom of the program.
![[Image: mipcwBr.png]](http://i.imgur.com/mipcwBr.png)
write the following code in Bold to the fragment_main.xml between the LinearLayout.
We have a couple of types of Layouts ,
RelativeLayout You can change the position of the objects inside it as you want.
LinearLayout You cannot change the position of the objects inside it as you want,
the objects can either be on top of each other or next to each other depending on the orientation you want.
TextView this is used to show a message on screen.
Button this is used to create a button on screen.
TextView & Buttonare made of attributes , they define what these GUI components will
look like and what information do they have.
android:layout_width is an attribute responsible for the width of the objects we have ie.
textview or button ..etc they can take three values ,fill_parent, match_parent, wrap_content.
android:layout_width is an attribute responsible for the height of the objects we have,
they take three values ,fill_parent,match_parent,wrap_content.
android:text this attribute holds the text that you want to show to the user.
match_parent will result in having the same width/height as the parent (the amount the linearlayout has or relative layout has).
fill_parent this will fill the parent box.
wrap_content will use as much as the content of the object (textview / button ..etc).
"More about TextView, Button & attributes in later tutorial"
Now time to run our application
To run the application click File->Run As-> Android Application
![[Image: IvR3wkn.png]](http://i.imgur.com/IvR3wkn.png)
After that the Android Emulator that you created "if not check previous tutorial link at start of page" should load and run the application.
Hope you enjoyed creating your first application
If you face any problem don't be afraid to ask in this thread I will check them as soon as I can
Regards Netero
With the tools & SDK downloaded and installed, "if you didn't already install the SDK files & the tools necessary read This",
we will begin by creating the classical Hello World! application
so lets get started.A note before we begin, I don't explain somethings because it will confuse you since you are a starter on Android Development ,
follow my future tutorials and you will be able to understand things that you currently don't understand/ I didn't explain in future Tutorials.
Part One : Setting up Project
Using Eclipse create a new project by selecting File->New->Android Application Project (see figures below)
Spoiler: Click Me
![[Image: nifdJMX.png]](http://i.imgur.com/nifdJMX.png)
Then you will get a window like the figure below.
Spoiler: Click Me
![[Image: 2bWKg3f.png]](http://i.imgur.com/2bWKg3f.png)
Application Name:It's the name of the application on the Android phone.
Project Name:As the name says its the name of the project, basically this name is used for you "The Developer" to identify your project later when/if you want to modify.
Package Name:Applications are made up of many packages , they contain codes you define,maybe you are working with a team
and each one of you are responsible for a package (ie. codes).Usually the name of the main package is the reverse domain
"example com.hackacademy" you can chose any name you like, but the reverse domain name is general.
The codes that we write are called source code, like many programming languages Java is a compiled language,
meaning it needs another program called compiler to translate the codes from source code
"readable codes by human" to machine code "codes understandable by computer made of 0 and 1".
Minimum SDK required:Is the minimum android version that can run our program.
As stated in first tutorial each version have its own characteristics , programs that are written for Higher versions
cannot run on the low versions, that's the basic idea.So when we choose the minimum SDK we are saying that the
minimum version that can run the code is (in this example its Froyo).Some features are made
for specific versions and following versions we must know if the minimum version that we are coding for
supports our code or not "More about this in later tutorial".
Target SDK:The Android version that we want are specifically coding for. (sorry if I couldn't explain this well).
Compile With:The compiler program that we use to change the source code to machine code, almost all the time you will compile with the same version as Target SDK.
Theme:This is the base theme used in our application. "More about this in later tutorial"
Then click next, and you will get the following window.
Spoiler: Click Me
![[Image: 4G7TfgL.png]](http://i.imgur.com/4G7TfgL.png)
Create custom launch icon This will allow you to create your own Icon "more on this in next image".
The other parts I will talk briefly, but usually you will leave it as it is for the applications that you will develop.
Start activity basically this means to create a GUI window.
Mark this as a Library Our applications are mostly a mixture of these codes, codes that have been developed
by Google or other developers, these codes are ready to be used. "More about this in later tutorial".
Click Next then following window will come.
Spoiler: Click Me
![[Image: JNuCFVk.png]](http://i.imgur.com/JNuCFVk.png)
You can create a custom application image/icon in here, I prefer if you play with this one and experiment to what the different options give you.
Click Next , start Blank activity then click Next.
And you will get this window
Spoiler: Click Me
![[Image: woW6Voh.png]](http://i.imgur.com/woW6Voh.png)
Activity Main is the name of the Main class, the class where the application starts.
Layout Name the graphical layout "GUI" that the program will load when program starts.
Fragment Layout "More about this in later tutorial"
Navigation Type the type of navigation which your application supports, ie. Navigation Drawer ,Action bar tab...etc "More about this in later tutorial"
Then click Finish
Now we finished setting up our first project

Lets write a few codes
but before that do the following final steps.Part Two : Writing our First Program

If the IDE (Eclipse) didn't open the two files fragment_main.xml & MainActivity.java (if you didn't the names 2 steps before now).
In the package explorer, expand your project and expand the res folder then open the fragment_main.xml.
.xml Files define the user interface of your application.The default view is "Linear Layout".
To modify the fragment_main by hand click on the fragment_main.xml located in the bottom of the program.
Spoiler: Click Me
![[Image: mipcwBr.png]](http://i.imgur.com/mipcwBr.png)
write the following code in Bold to the fragment_main.xml between the LinearLayout.
Code:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is my first application" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="And this is a clickable Button" />We have a couple of types of Layouts ,
RelativeLayout You can change the position of the objects inside it as you want.
LinearLayout You cannot change the position of the objects inside it as you want,
the objects can either be on top of each other or next to each other depending on the orientation you want.
TextView this is used to show a message on screen.
Button this is used to create a button on screen.
TextView & Buttonare made of attributes , they define what these GUI components will
look like and what information do they have.
android:layout_width is an attribute responsible for the width of the objects we have ie.
textview or button ..etc they can take three values ,fill_parent, match_parent, wrap_content.
android:layout_width is an attribute responsible for the height of the objects we have,
they take three values ,fill_parent,match_parent,wrap_content.
android:text this attribute holds the text that you want to show to the user.
match_parent will result in having the same width/height as the parent (the amount the linearlayout has or relative layout has).
fill_parent this will fill the parent box.
wrap_content will use as much as the content of the object (textview / button ..etc).
"More about TextView, Button & attributes in later tutorial"
Now time to run our application

To run the application click File->Run As-> Android Application
Spoiler: Click Me
![[Image: IvR3wkn.png]](http://i.imgur.com/IvR3wkn.png)
After that the Android Emulator that you created "if not check previous tutorial link at start of page" should load and run the application.

Spoiler: Final Imagure
Hope you enjoyed creating your first application

If you face any problem don't be afraid to ask in this thread I will check them as soon as I can

Regards Netero
I'm too busy with Learning new things. Will check as much as I can.
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)

