Thursday, March 29, 2012

Bind Spinner (Dropdown) Android

As a beginner, It is difficult to bind the data to Spinner (Drop down). If we consider HTML, it is easy to add option values to the drop down. But In Android, we have to use Adapters to bind the data. So here I am targeting my approaches to bind to the Spinner. 

Binding static Array to the spinner

static final String[] COUNTRIES = new String[] { "India", "US", "UK",
   "Sri Lanka", "Austraila", "Denmark", "Saudi" };

Spinner spCountry = (Spinner) findViewById(;

ArrayAdapter<CharSequence> adCountry = new ArrayAdapter<CharSequence>(
                this, android.R.layout.simple_spinner_dropdown_item, COUNTRIES);  


Binding resource Array to the Spinner

Spinner spCities = (Spinner) findViewById(;

String[] cities = getResources().getStringArray(R.array.arr_cities);

ArrayAdapter<CharSequence> adCities = new ArrayAdapter<CharSequence>(
       this, android.R.layout.simple_spinner_item, cities);



Binding resource Array to the Spinner Using ArrayAdapter.createFromResource

Spinner spLocalities = (Spinner) findViewById(;

ArrayAdapter<CharSequence> adLocalities = ArrayAdapter
   .createFromResource(this, R.array.arr_localities,android.R.layout.simple_spinner_item);



References : download_source_code

Monday, March 26, 2012

Openframeworks Vs A Day Made of Glass

Few days ago, I watched a video - "A day made of glass".My reaction was, "When will I see this technology in action?"

Few months later, I found one framework by name "OpenFrameworks". I realize that the things that were shown in " A day made of Glass" are possible by this framework.

Here is the one of the most popular game - SNAKE, implemented using openframeworks in a different way.


Wednesday, March 7, 2012

Android Preparing Development Environment

I feel many developers wants to write mobile app and run in their mobile. Tools are plays important role while developing any application. Like wise, If you want to develop android app, first you need to prepare develop environment. In this post will see how to install and create hello world project.

What to install ?
  1. Java ( JDK5 or JDK6 or any latest version )
  2. Android
    1. SDK
    2. Platforms ( at least one )
  3. Eclipse
  4. Eclipse ADT

If Java is not installed in system, you need to download the java file from the following link and install it.

Android SDK

If Android SDK is not installed in system, you need to download the SDK file from the following link and install it.


If Eclipse is not available in machine, you need to download from the following link.

Note: No need to install eclipse, download and extract the eclipse. You will find eclipse.exe, just open this. 

Eclipse ADT

  1. Start Eclipse, then select Help > Install New Software....
  2. Click Add, in the top-right corner.
  3. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:
  1. Click OK
Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
  1. In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
  2. In the next window, you'll see a list of the tools to be downloaded. Click Next.
  3. Read and accept the license agreements, then click Finish.
Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.

Android Platforms

After successful installation, you will find SDK Manager.exe or AVD Manager.exe files in android installation folder.
  • Open the SDK Manager.exe, you will find the following screen
  • Select the platforms which you want to install. (it is better to install Eclair[ 2.1 ], Froyo[ 2.2], Gingerbread[2.3.3] and Honey Comb coz will find only these platforms in mobiles and tabs as per present market)
  • Click on the Install Packages and then select Accecept all, Click install

  • After successful installation, open the AVD Manager and create virtual device by clicking New button

  Creating Helloworld project
  1. Open eclipse by clicking on eclipse.exe
  2. Click on File -> New 

 3. Select the Android project
 4. Will find Create New Project Window, type the Project Name as Helloworld
 5. Next screen, will find Select Build target window. Select target platform, Click next

6. Here you will find Application name and project name. Type some names and click on the Finish button.

7. Run the application by clicking Run button and select Run as Android project.

You done... You will be able to see hello world application in Emulator.

Good luck :-)

References :