Today We’re Covering…
We’ll learn how to:
Edit layout/main.xml using the visual tool given by ADT by adding a TextView and a Button in a LinearLayout (more on layouts will be covered later)
- Application Structure
- Android Application Anatomy
- Activity
- Layout
- Using Layouts from Activity
- Activity Lifecycle
Project Structure…
Created Project has the following structure
In the HelloActivity class, the screen layout is set by main.xml given below:
-res/layout/main.xml
1.UI Layout can be defined from source code using View or by layout xmls.
2.The layout xml can be generated by visual tool given by ADT
-res/drawable
1.From Android 1.6 to support different screen sizes and screen densities graphic files are kept in 3 different folders drawable-hdpi, drawable-ldpi and drawable-mdpi
2.In our current project, they contain only default icon file with different dimensions to support devices with different screen resolution.
-assets
Holds other static files you wish packaged with the application for deployment onto the device. In this project, we have none
-gen/R.java
-values/strings.xml
-AndroidMenifest.xml
XML file describing the application being built and what components – activities, services, etc. – are being supplied by that application
Let’s Build Something Useful…
Objective: To get hands-on experience of building something useful more than just “Hallo World”.
Plan: We’ll create a project to show how the basic building block Activity and some UI elements work.
Output: User will push a button and see current time.
We’ll learn how to:
1.Design UI from layout XML
2.Set the layout in an Activity
3.And make UI elements in action
Creating the Project:
Start Eclipse and go to New>Project>Android Project
Designing Layout
Edit layout/main.xml using the visual tool given by ADT by adding a TextView and a Button in a LinearLayout (more on layouts will be covered later)
launcher (to allow users to launch this activity).
Creating Activity
We have already created Activities. But how did we create it?
Let’s revisit…
2.We implemented one callback method onCreate
Open Questions:
1.What is creating subclass???
2.What is callback methods???
Next Step: Implementing User Interface
1.Design res/layout/yourlayout.xml
2.Use Views from Activity class
Next Step: Starting Activity
We can start another activity by calling startActivity(), passing it an Intent that describes the
activity you want to start.
Intent intent = new Intent(this, ToActivity.class);
startActivity(intent);
Android Application Anatomy
No comments:
Post a Comment