Hello Android - Your first Application

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Hello Android - Your first Application

Postby plusminus » Fri Nov 16, 2007 1:46 pm

Building your very first "Hello Android" - Application


What is this: This tutorial shows how to create the simplest application possible at all.
What you learn: Create an Android-Project in Eclipse, alter some code and create a Run-Configuration.

Difficulty: 0.5 of 5 :wink:

What it will look like:
Image


Follow these steps:
1. At first, we have to create a new Project. Right-Click on some free space in your Package-Explorer.
Image

[hr]
2. Select "Android Project"
Image

[hr]
3. Fill out the form with the Structures you like...
Image

[hr]
4. This all is the code for your first Android-Application (don't panic, mostly all of them are resource-files)
Image

[hr]
5. Navigate to the "Hello_Android.java" and replace the text with the following:
You find the copy-paste-able text on the end of this Post...

Image

[hr]
6. Open the Run--DropDown in the upper menu and Click "Open Run Dialog..."
Image

[hr]
7. Click on browse and select your project (there should be just this one). Done that, click Apply and then Run.
Image

[hr]
8. The Emulator is booting...
Image

[hr]
9. The "Home"-App is loading...
Image

[hr]
10. Congratulations, this is your very first Hello-Android-Application!
Image

[hr]

The full source
:roll:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package org.anddev.android.Hello_Android;
  2.  
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5. import android.widget.TextView;
  6.  
  7. public class Hello_Android extends Activity {
  8.     /** Called when the activity is first created. */
  9.     @Override
  10.     public void onCreate(Bundle icicle) {
  11.         super.onCreate(icicle);
  12.         // We want to view some very simple text, so we need a TextView
  13.         TextView tv = new TextView(this);
  14.         // Put some text to the newly created TextVIew
  15.         tv.setText("Hello Android - by: anddev.org n" +
  16.                         "This is soooo simple =D ");
  17.         // Tell our App to display the textView
  18.         this.setContentView(tv);
  19.     }
  20. }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Last edited by plusminus on Sat Jun 14, 2008 9:42 am, edited 1 time in total.
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby tum0rc0re » Sun Nov 25, 2007 7:29 am

Thanks for this article :) I just begin to learn Android and all articles from this forum are very useful for me :D
User avatar
tum0rc0re
Senior Developer
Senior Developer
 
Posts: 158
Joined: Sun Nov 25, 2007 7:15 am
Location: Moscow, Russia

Postby plusminus » Sun Nov 25, 2007 10:42 am

Hello tum0rc0re,

Thanks :) .

And You can help to spread this even more!
As we are already the board with the most visitor (400 uniques /day :!: ) and non-fake topics/posts and with the most real users (there are so fuc**** much fake-boards with hundreds of fake-topics, having each about 5 reads :evil: ),
we have unfortunately dropped far in the Google-Search-Rankings, being overtaken by fake-stuff :evil: . Thant sucks hard :!:

We do need the help of the Community :!:

:arrow: Tell you friends/fellow programmers of this board, make a post in your blog, to keep this the best resource for learning/discussing Android from now until .... ever :)

Best Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby tum0rc0re » Sun Nov 25, 2007 11:29 am

plusminus, ok :) Although, my friends are not interested Android platform, but I post ad in my blog :) Here - http://tum0rc0re.blogspot.com/2007/11/n ... forum.html
User avatar
tum0rc0re
Senior Developer
Senior Developer
 
Posts: 158
Joined: Sun Nov 25, 2007 7:15 am
Location: Moscow, Russia

Postby plusminus » Sun Nov 25, 2007 5:06 pm

:D Thank you. Everything helps :!:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Re: Building your very first "Hello Android" - App

Postby adsouza » Sun Nov 25, 2007 9:55 pm

[font=Comic Sans MS]hello plusminus:

my gosh! i just had a look at your tutorial and
was flabbergasted. :shock:

terrific! with pictures and so on. :D

thank you very much indeed. :roll:

Aaron
[/font]
adsouza
Freshman
Freshman
 
Posts: 6
Joined: Fri Nov 16, 2007 6:44 am
Location: Pune, India

Top

Postby plusminus » Sun Nov 25, 2007 10:10 pm

I'm just making them the way I would like them best :)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby XterierK » Mon Nov 26, 2007 7:34 am

This site will be growing at the rate these tutorials are being produced, your amazing, thanks!
Limited Imagination = Impossible!
XterierK
Freshman
Freshman
 
Posts: 4
Joined: Mon Nov 26, 2007 7:22 am

Postby WinerFresh » Mon Dec 03, 2007 5:20 pm

It can be easier(maby only for me :D ).
The code - Hello.java is:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.winerfresh.hello;
  2.  
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5.  
  6. public class Hello extends Activity {
  7.     /** Called when the activity is first created. */
  8.     @Override
  9.     public void onCreate(Bundle icicle) {
  10.         super.onCreate(icicle);
  11.         setContentView(R.layout.main);
  12.     }
  13. }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

The code - main.xml is:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.    android:orientation="vertical"
  4.    android:layout_width="wrap_content"
  5.    android:layout_height="wrap_content"
  6.    >
  7. <TextView  
  8.    android:layout_width="wrap_content"
  9.    android:layout_height="wrap_content"
  10.    android:text="@string/tekst"
  11.    />
  12. <TextView  
  13.    android:layout_width="wrap_content"
  14.    android:layout_height="wrap_content"
  15.    android:text="@string/tekst2"
  16.    />
  17. </LinearLayout>
  18.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4

and the code - strings.xml is
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3.     <string name="app_name">Hello world, android!</string>
  4.     <string name="tekst">Hello world<br /></string>
  5.     <string name="tekst2">tested</string>
  6. </resources>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
WinerFresh
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Dec 03, 2007 5:10 pm

Postby plusminus » Mon Dec 03, 2007 8:49 pm

Hello winerfresh,

thanks for your code, but we have almost the same :arrow: here.

Best Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Very nice tutorial!

Postby ramcosca » Wed Dec 05, 2007 3:57 am

Awesome.

I'm going to start learning to develop for Android after the 13th, when I finish my final exams. During my breaks I've been looking for sites to help me but many are just so advanced. I know nothing of Java / JavaScript. I hope that with these simple tutorials I'll be able to help and push Android at least a bit forward.

Hurrah for Android, hurrah for this site. Congratulations on making such a dev / future dev magnet!

By the way, off-topic, man what version of phpBB is this? I like it a lot! Tons of features I had never seen!
May the force be with you... always.
ramcosca
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Dec 05, 2007 3:47 am
Location: Humacao, Puerto Rico

Re: Very nice tutorial!

Postby plusminus » Wed Dec 05, 2007 10:36 pm

Hello ramcosa,

at first: thx for the laud =)
This site would be nothing without this community :!:

ramcosca wrote:I know nothing of Java / JavaScript. I hope that with these simple tutorials I'll be able to help and push Android at least a bit forward.


You should get to know at least some basic principles about Java (the whole Object-Orientated thing), before starting with Android.

ramcosca wrote:Hurrah for Android, hurrah for this site. Congratulations on making such a dev / future dev magnet!

:) it is a lot of work, but as I can see, how many people are reading all this (most tutorials have ~ 1000 Reads by now :!:) it makes me (and the others too) work even more :)

ramcosca wrote:By the way, off-topic, man what version of phpBB is this? I like it a lot! Tons of features I had never seen!


Its phpBB2 with at lot of extra Mods (also some own), like Attachment, AdvancedBB, AntiSpam, SyntaxHighliting ,...

At this point a big thx to madmax how is the MainAdmin of all that php-stuff :)

Best Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

unparsed aapt error

Postby tijames » Thu Dec 20, 2007 3:32 am

In Eclipse it says in problems that I have unparsed aapt error(s)

Location is unknown, can someone tell me me how to fix this?

And just so you know, I'm running a powermac G5 and using eclipse version: 3.3.1.1

Thanks a lot.
tijames
Freshman
Freshman
 
Posts: 9
Joined: Thu Dec 20, 2007 3:25 am

Postby plusminus » Thu Dec 20, 2007 3:23 pm

Hello tijames,

are you using a >SUN< JDK :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby tijames » Fri Dec 21, 2007 3:09 am

Well I don't think so (sorry, I'm an uber-nOOb).
Anyway, I first downloaded Eclipse - Europa for mac and got the ADT plugin for it.
Then I downloaded the SDK, put it into my documents, linked eclipse to it and then started trying to create the Hello_Android app. When I tried to run it, it said that the aapt file was unparsed, I looked in the console to see where it is and I found it inside the SDK.
I opened the inspector in mac OS X and read the info on the aapt, it said it was a unix executable file (intel) and I have a PowerPC mac so yeah.... I'm just wondering if there is anyway around the problem?
tijames
Freshman
Freshman
 
Posts: 9
Joined: Thu Dec 20, 2007 3:25 am

Top
Next

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests