p1

Getting Started with Android Programming


When ever i start with new programming language i always start with getting a popup box or alert box. So in this tutorial will see how to get a popup message in an android application.

Here are some pre-requisites that are required for running an android project:

    Android-SDK
    ADT
    Eclipse
    Basic Java Knowledge


In this project we will be creating a TOST(a popup message) to display "Hello World".
One of the most easy part in android, you may look at the code below:

   Toast.makeText(--APP CONTEXT--, --Text-- , --Length--).show();


The above code will display a small popup message on to the screen.
You first need to create an Activity and a class associated to the activity, So on create of this method you may write the Tost code.


package com.example.demoui;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import android.support.v4.app.NavUtils;

public class NewUI extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new_ui);
        Toast.makeText(getApplicationContext(), "Hello World", Toast.LENGTH_SHORT).show();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_new_ui, menu);
        return true;
    }    
}


Understand in detail about the function :

--App Context-- : The context of the Application/Activity.
--Text-- : The text your need to display on the screen.
--Length-- : For how long the text should be displayed (Toast.LENGTH_SHORT, Toast.LENGTH_LONG).


Thats it guys ... you have started writing code in android. Soon will post how to setup development environment for android.

Read more
p1

Applying HOLO theme to android

When i started my development in android, i always used to wonder how to modify the UI, how can i make it better or how will it look nicer. As am a web developer i always want the UI to be good looking....

So after roaming around on internet i could found few styles provided by android 3.0+ and some from custom framework like "Action Bar Sherlock".

Today will use HOLO theme provided by android itself and will see how easy it is to implement it.
By default android UI SUCKS big time and doesn't look nice at all so either you can customize the style.xml file in res->layout->values and try something creative. But if you want to have simple color changes and u want to use latest android 4.0 ui then follow simple steps:

Step 1: Visit http://android-holo-colors.com/, this site will provide ready made styles for holo UI.
need to select the color as per your need and what all objects you need to modify as per the image then download the zip file, the contents should be as follows:


drawable -- Styles for all the basic objects used in UI(Edit Text)
drawable-hdpi -images
drawable-mdpi -images
drawable-xhdpi -images
values (Android version < 3.0)
'----> customtheme_styles.xml
'----> customtheme_themes.xml
values-v11 (Android Version > 3.0)
'----> customtheme_styles.xml
'----> customtheme_themes.xml


Step 2: Create the android project with default activity with Target as 4.0

Step 3: After Creating the project, we need to copy all the above files res folder.
Now you will observe that there is an extra folder values-v14, that is because above Android 4.0 the styles change. So you may copy the same styles in values-v11 to values-v14.

Step 4: You need to tell android to look up for a specific theme. So as our theme name is customtheme we can directyly modify the AndroidManifest.xml, so we need to change
android:theme="@style/AppTheme"
to
android:theme="@style/customtheme"


Thats all what we need to do, Automatically R.java will be build and we could get stunning UI and customize it the way we wanted :). I will be glad to help you if you need anything from me.
Download The Project

Read more