Você está na página 1de 4

Android Adventures - Getting Started With Android Studio Página 1 de 4

Login Register Edit Profile Change Region About Us

Home The Core Android

Main Menu Android Adventures - Getting Started With


• Home Android Studio
• Book Reviews Written by Mike James
• News Monday, 20 May 2013 00:00
• Projects
• The Core Article Index
Android Adventures - Getting Started With Android Studio
◦ WPF Workings Project Structure
◦ Silverlight From Code to Emulator
◦ Java Running the App
◦ Joomla Page 2 of 4
◦ PHP
◦ JavaScript
The next dialog box allows you to select the icon used for your
◦ C#
app - just select Next there is time to work on custom icons
◦ Visual Basic
when you have an app that is worth the effort:
◦ C/C++
◦ Other Languages 1,496 followers
◦ Theory
◦ Artificial Intelligence
◦ Mobile
◦ Database
◦ ASP .NET
◦ Hardware
◦ Graphics and Imaging
◦ UI/UX
◦ Perl
◦ WinRT
◦ HTML/CSS
◦ Python
◦ jQuery
◦ Ruby
◦ Android

• Babbage's Bag
• History
• Swift's Spreadsheets
The next dialog box asks you to select the type of Activity you
• The Stone Tapes
want to create. Every Android app consists of at least one
• Professional Programmer
Activity - you can think of it as the basic unit of app
• eBooks
construction. We need to talk much more about Activities later
• Programmer Puzzles
but for the moment simply select a Blank Activity.
• Bargain Computer Books
• CodeBin
• I Programmer Weekly

search...

Search

Selecione o idioma
Powered by Tradutor

New Articles!
• ICT 1301 - A 1960's
Computer
• Web Components With X
-Tag
• A Programmer's Guide to
Scratch 2 Finally you have to give your Activity a name - for the moment
• Android Adventures - just accept the default of MainActivity.
Pickers
• Functional And
Dysfunctional
Programming
• Magic of Merging
• Merkles and Social
Engineering
• History of Computer
Languages - the classical
decade, 1950s
• Android Adventures -
Spinners And Pickers

http://www.i-programmer.info/programming/android/5887-android-adventures-gettin... 21/10/2013
Android Adventures - Getting Started With Android Studio Página 2 de 4

• Turing's Test, the


Loebner Prize and
Chatterbots
• Date Hacks - Doing
JavaScript Date
Calculations
• ERNIE - A Random
Number Generator
• Javascript Jems - Active
Logic, Truthy and Falsey
• Kolmogorov Complexity

New Book Reviews!


• HTML5 Pocket Primer
• Algorithms Unlocked
• Database Design for
Mere Mortals
• Pro JavaScript
Performance When you click the Finish button Android Studio starts to build
• Hello! iOS Development your project. It can take a few minutes so don't assume it has
• Python: Visual QuickStart crashed.
Guide (3rd Ed)
• Beginning R: An
Introduction to Statistical
Programming
Basic Project Structure
• Classic Game Design When the project has finished building all of the files created can
• HTML5 Unleashed be viewed by opening the Projects tab. The main thing to notice
• Pro T-SQL 2012 is that there are a great many folders and files. It seem almost
Programmer’s Guide unbelievable that the simplest Android app you can create
• jQuery Mobile: Develop involves so many files.
and Design
Don't panic.
• Kodu for Kids
• Microsoft SharePoint Most of the files that have been created are autogenerated and
2013 Developer most of the time you don't need to know anything about them let
Reference alone open or edit them. In fact opening and editing
• Programming Android autogenerated files really isn't a good idea.
(2e) For our simple program there are only two important files one
• Beginning DB2 From that determines the Activity's behavior
Novice to Professional
MainActivity.java
and one that determines most of the visual appearance
Popular Articles Main_Activity.xml
• Dumping .NET - You can set which activity is the one that the system starts but
Microsoft's Madness by default it is the single activity that you created and named
• Using the WPF .NET 4.0 when you set up the project. In this case we named the activity
DataGrid MainActivity and its layout file Main_Activity - but you could
• Getting Started with PC change these defaults.
Kinect
• Getting started with
Microsoft Kinect SDK
• JavaScript Data
Structures - Associative
Array
• Weak typing - the lost art
of the keyboard
• Data structures - Trees
• Was .NET all a mistake?
• Getting started with Excel
VBA
• Developing with PHP and
Eclipse (Galileo)

Popular Book
Reviews
• Beautiful Architecture:
Leading Thinkers Reveal
the Hidden Beauty in
Software Design
• Hello World! Computer
Programming for Kids
and Other Beginners
• Practical Raspberry Pi
• Beginning R: The
Statistical Programming
Language
• Algorithms in a Nutshell
• Programming: Principles
and Practice Using C++ The MainActivity.java file can be found in the src/main/java
• Android Apps Marketing directory and the Main_Activity.xml file can be found in
• The Ruby Programming src/main/res/layout directory. The src directory is from your point
Language of view where most of the construction of your app occurs so
• How We Test Software at make sure you know where it is. The src/main directory is where
Microsoft you keep the files concerning the main Activity and the Java
• Simply Javascript code goes in Java and the various resource files belong in res.

Anatomy Of An Activity

http://www.i-programmer.info/programming/android/5887-android-adventures-gettin... 21/10/2013
Android Adventures - Getting Started With Android Studio Página 3 de 4

An Android app is made up of one or more Activities. You can


think of an Activity as being something like a web page
complete with HTML to determine what displays and JavaScript
to determine what it does.
In the case of an activity the layout is determined by the XML file
in resource (res) directory and the behavior is determined by the
Java code in the Java directory.
The XML can be thought of as a markup language much like
HTML or XAML. It defines an initial layout for the screen when
the app first runs. It is possible to generate new layout
components are run time from the Java file. In fact if you really
want to you can dispense with the XML file and generate
everything from Java but as you will discover the XML markup
approach is much the best way to do the job - because of the
availability of the Designer.
Let's take a look at the two files that have been generated for
our initial Hello World application beginning with the XML
layout.

Hello Designer
First the XML layout file. Double click on activity_main.xml file in
the Project tab and the file will open - but not as an XML file as
you might expect. What you see when you open a layout file is
the drag-and-drop layout designer.
This looks a little too much to take in when you first see it but
you will quickly get used to it.
On the left is a Palette of all of the components - buttons, text,
checkboxes and so on - that you can place on the design
surface.
In the middle is the design surface and this defaults to the
screen size and appearance of the Nexus 4. You can select
other devices to work with.
On the right you have the Component Tree which shows you the
structure of your layout - its the same as the nesting structure of
the XML file. Below the Component Tree you have the
Properties window that can be used to set the properties of any
component in the layout.
If you have used any drag-and-drop designer then this one will
be familiar to you. If you have struggled with the detailed layout
using a markup language be it HTML, XAML or XML then you
will like how easy the designer makes building and testing a UI.
In the case of our sample program the only component uses is a
single TextView already containing the text "Hello World". You
can modify the greeting text if you want to. Select the TextView
component and use the Properties window to find its Text
property. Change this to read "Hello Android World". Don't worry
about the form of the original entry starting with an @ and
looking complicated just type the string in as given.

You can use the designer to create any UI you care to and you
really don't have to get involved in the XML that corresponds to
the layout. The designer will automatically generate the XML
needed to create the layout for you and modify it as you change
the layout. If you really want to see the XML then all you have to
do is select the Text tab at the bottom of the designer window.
You should find it fairly easy to understand but leave it to the
designer to modify it.
We will return to the designer and the XML it generates later.

<< Prev - Next >>

Last Updated ( Tuesday, 08 October 2013 12:42 )

Copyright © 2013 i-programmer.info. All Rights Reserved.

http://www.i-programmer.info/programming/android/5887-android-adventures-gettin... 21/10/2013
Android Adventures - Getting Started With Android Studio Página 4 de 4

Ver esta página em: português Traduzir Desativar para: inglês Opções ▼

Download Android Apps


MoboGenie.com/Download-Android-Apps

Largest Collection of Android Apps. Save Data Cost. Try Mobogenie Now!

Powered by Joomla!. ValidXHTML and

http://www.i-programmer.info/programming/android/5887-android-adventures-gettin... 21/10/2013

Você também pode gostar