Android
|
Modified: |
Overview
To start to understand an Android app, we will create the default app in Eclipse and examine the files created.
Starting at IUS
- Copy C:\temp\.android C:\Users\username\.android
- Start Eclipse by opening
C:\eclipse-jee-indigo-win32\eclipse and clicking- Select your workspace for saving files.
Set the Android SDK location by:
Window | Preferences | Android | SDK Location: C:\Progra~1\Android\android-sdk
- File | New | Project | Android
Name the project Test1
Check Build Target Android 3.2
Package name with at least one . in the name.
Click Finish.
- To open the Project Explorer click the icon in the lower-left of the Eclipse window or Java in the upper-right.
- Open Test1/src/edu.../Test1Activity.java
- Click the upper-left bug and debug as Android Application.
- After a bit of a wait and with luck, you'll see the emulator:
- Drag the lock and you should see the results of Test1.
Two Java files define the code behind the app, two XML files define the view.
- Click on Java in the upper-right corner to open the Package Explorer.
Window | New Window
Expand to display as below:
TestActivity1.java
- Inherits from Activity, essentially the execution of the app, more detail at: http://developer.android.com/reference/android/app/Activity.html
- setContentView(R.layout.main); sets the visible view to whatever is in XML file R.layout.main
R.java
- Defines symbolic constants that corresponds to XML.
- XML elements in strings.xml are constants in the class string.
main.xml
- Default view definition.
- Uses symbolic name android:text="@string/hello" to access string.xml and hello definition.
string.xml
- Default string definition file.
- hello definition.
|
|
Add your name as part of the view.
Use either the graphical or XML file editor.