Home > Uncategorized > Say Hello World – Native Android app

Say Hello World – Native Android app


Normally, I write Android apps using PhoneGap / Cordova, but I wanted to start looking into native apps, to tap into features such as SQLLite etc.

So, Here’s a first go at “Say Hello World”, an app with a button that pops up a toast saying “Hello World”.

I used eclipse to create a new blank Android app, then dropped a button onto the form. Set it’s ID to btnSayHello

Then in MainActivity.java I added the following code:

Button button = (Button)findViewById(R.id.btnHello);
button.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), “Hello”, Toast.LENGTH_SHORT).show();

And, then following the prompts by eclipse, added some necessary imports


import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

Bit of trial and error, but it’s starting to make sense…


Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: