12+ EditText in Android Example Codes, Screenshots and More!

Hi guys! Today I’m gonna show you some Android EditText examples that I usually use in my android applications. EditText in Android examples are simply like a text field, text area or a text input field in online forms. It is an editable TextView.

EditText in Android Example List

In this post, we will cover:

1. Creating EditText Programatically

1.1 How to Create an EditText Programatically.

2. EditText maxLength and digits Restrictions

2.1 Set Maximum Number of Characters that can be Entered to an EditText.
2.2 Set EditText to accept numeric characters only.

3. Button-triggered EditText and Input Types

3.1 How Get Value from an EditText Programatically.
3.2 How to Assign Value to an EditText.
3.3 How to Clear Value of an EditText.
3.4 EditText Input Types with Screenshots and XML Layout Codes

3.4.1 Plain Text Input
3.4.2 Password Input
3.4.3 Email Address Input
3.4.4 Phone Number Input
3.4.5 Number Input
3.4.6 Signed Number Input
3.4.7 Decimal Number Input

3.5 Section 3 Complete Code
4.0 Section 3 Code Download

1. Creating EditText Programatically

1.1 How to Create an EditText Programatically?

Android Code:

EditText editTextName = new EditText(this);
editTextName.setText("Mary");

2. EditText maxLength and digits Restrictions

2.1 Set Maximum Number of Characters that can be Entered to an EditText.

<!-- Set MaxLegth EditText -->
<TextView
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="Set MaxLegth of 5 for EditText:" />

<EditText
   android:id="@+id/editText3"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:maxLength="5">
</EditText>

2.2 Set EditText to accept numeric characters only.

<!-- Allow digits 0,1,2,3,4,5 Only. 6, 7, 8, 9 is not allowed. -->
<TextView
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="Allow Digits 0,1,2,3,4,5 Only:" />

<EditText
   android:id="@+id/editText4"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:digits="012345" />

3. EditText Listeners and Input Types

3.1 How Get Value from an EditText Programatically?

Tapping “Show Plain Text Input” button will show a Toast with value of our edittext for plain text input.

android How Get Value from an EditText Programatically

Android code:

final EditText editTextPlainTextInput = (EditText) this.findViewById(R.id.editTextPlainTextInput);

Toast.makeText( MainActivity.this, "Plain Text Input: " + editTextPlainTextInput.getText().toString(), Toast.LENGTH_SHORT).show();

3.2 How to Assign Value to an EditText?

Tapping “Assign Number Input to Plain Text Input” button will copy the value of our EditText for number input and put it to our EditText for plain text input.

android - How to Assign Value to an EditText

Android code:

// plain text input
final EditText editTextPlainTextInput = (EditText) this.findViewById(R.id.editTextPlainTextInput);

// number input
final EditText editTextNumberInput = (EditText) this.findViewById(R.id.editTextNumberInput);

String number_value = editTextNumberInput.getText().toString();
editTextPlainTextInput.setText(number_value);

3.3 How to Clear Value of an EditText?

Tapping “Clear Plain Text Input” button will empty our EditText for plain text input and only show the “hint” we specified on the XML (in our example the hint is “Type who your are.”).

android - How to Clear Value of an EditText

Android code:

final EditText editTextPlainTextInput = (EditText) this.findViewById(R.id.editTextPlainTextInput);

editTextPlainTextInput.setText("");

3.4 EditText Input Types

3.4.1 Plain Text Input

Softkeyboard allows you to use any characters available.

edit text plain text input

XML code:

<EditText
    android:id="@+id/editTextPlainTextInput"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textViewPlainTextInput"
    android:hint="Type who you are."
    android:singleLine="true" >
</EditText>

3.4.2 Password Input

Softkeyboard allows you to use any characters available. The EditText field will show only black dots.

android edittext password input

XML code:

<EditText
    android:id="@+id/editTextPasswordInput"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textViewPasswordInput"
    android:inputType="textPassword" >
</EditText>

3.4.3 Email Address Input

Softkeyboard shows the @ and .com buttons this time.

android edittext email address input

XML code:

<EditText
    android:id="@+id/editTextEmailAddressInput"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textViewEmailAddressInput"
    android:inputType="textEmailAddress" />

3.4.4 Phone Number Input

Softkeyboard allows you to enter numbers and any characters acceptable for phone numbers like *, #, -, etc.

android edittext phone number input

XML code:

<EditText
    android:id="@+id/editTextPhoneNumberInput"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textViewPhoneNumberInput"
    android:inputType="phone" />

3.4.5 Number Input

Softkeyboard allows you to enter only numbers this time.

android edittext for number input

XML code:

<EditText
    android:id="@+id/editTextNumberInput"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textViewNumberInput"
    android:inputType="number" />

3.4.6 Signed Number Input

Softkeyboard allows you to enter numbers and negative sign.

android edittext Signed Number Input

XML code:

<EditText
    android:id="@+id/editTextSignedNumberInput"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textViewSignedNumberInput"
    android:inputType="numberSigned" />

3.4.7 Decimal Number Input

Softkeyboard allows you to enter only decimal numbers.

android edittext Decimal Number Input

XML code:

<EditText
    android:id="@+id/editTextDecimalNumberInput"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textViewDecimalNumberInput"
    android:inputType="numberDecimal" />

3.5 Section 3 Complete Code

Here’s the complete code for section 3.

MainActivity.java – includes the button click listener to perform actions with the EditText.

package com.example.androidedittextexample;

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

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try {

            // plain text input
            final EditText editTextPlainTextInput = (EditText) this.findViewById(R.id.editTextPlainTextInput);

            // number input
            final EditText editTextNumberInput = (EditText) this.findViewById(R.id.editTextNumberInput);

            View.OnClickListener handler = new View.OnClickListener() {
                public void onClick(View v) {
                    // we will use switch statement and just
                    // get thebutton's id to make things easier
                    switch (v.getId()) {

                    // toast will be shown with the
                    // EditText for plain text input
                    case R.id.ShowPlainTextInput:
                        Toast.makeText( MainActivity.this, "Plain Text Input: " + editTextPlainTextInput.getText().toString(), Toast.LENGTH_SHORT).show();
                        break;

                    // the value of EditText for number input
                    // will be the value of EditText for plain text input
                    case R.id.AssignToPlainTextInput:
                        String number_value = editTextNumberInput.getText().toString();
                        editTextPlainTextInput.setText(number_value);
                        break;

                    // the EditText for plain text input will be cleared
                    case R.id.ClearPlainTextInput:
                        editTextPlainTextInput.setText("");
                        break;
                    }
                }
            };

            // we will set the listeners of our three buttons
            findViewById(R.id.ShowPlainTextInput).setOnClickListener(handler);
            findViewById(R.id.AssignToPlainTextInput).setOnClickListener(handler);
            findViewById(R.id.ClearPlainTextInput).setOnClickListener(handler);

        } catch (NullPointerException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

activity_main.xml – XML layout with EditText and buttons.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <!-- we're using scroll view to see all contents -->
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <!-- EditText for plain text input -->

            <TextView
                android:id="@+id/textViewPlainTextInput"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="EditText For Plain Text Input:" />

            <EditText
                android:id="@+id/editTextPlainTextInput"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewPlainTextInput"
                android:hint="Type who you are."
                android:singleLine="true" >
            </EditText>

            <!-- EditText for password input -->

            <TextView
                android:id="@+id/textViewPasswordInput"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/editTextPlainTextInput"
                android:text="EditText For Password Input:" />

            <EditText
                android:id="@+id/editTextPasswordInput"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewPasswordInput"
                android:inputType="textPassword" >
            </EditText>

            <!-- EditText for email address input -->

            <TextView
                android:id="@+id/textViewEmailAddressInput"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/editTextPasswordInput"
                android:text="EditText For Email Address Input" />

            <EditText
                android:id="@+id/editTextEmailAddressInput"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewEmailAddressInput"
                android:inputType="textEmailAddress" />

            <!-- EditText for phone number input -->

            <TextView
                android:id="@+id/textViewPhoneNumberInput"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/editTextEmailAddressInput"
                android:text="EditText For Phone Number Input" />

            <EditText
                android:id="@+id/editTextPhoneNumberInput"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewPhoneNumberInput"
                android:inputType="phone" />

            <!-- EditText for number input -->

            <TextView
                android:id="@+id/textViewNumberInput"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/editTextPhoneNumberInput"
                android:text="EditText For Number Input:" />

            <EditText
                android:id="@+id/editTextNumberInput"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewNumberInput"
                android:inputType="number" />

            <!-- EditText for signed number input -->

            <TextView
                android:id="@+id/textViewSignedNumberInput"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/editTextNumberInput"
                android:text="EditText For Signed Number Input:" />

            <EditText
                android:id="@+id/editTextSignedNumberInput"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewSignedNumberInput"
                android:inputType="numberSigned" />

            <!-- EditText for decimal number input -->

            <TextView
                android:id="@+id/textViewDecimalNumberInput"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/editTextSignedNumberInput"
                android:text="EditText For Decimal Number Input:" />

            <EditText
                android:id="@+id/editTextDecimalNumberInput"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textViewDecimalNumberInput"
                android:inputType="numberDecimal" />

            <!-- Some options with EditText -->

            <!-- Button to clear plain text input -->
            <Button
                android:id="@+id/ClearPlainTextInput"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/editTextDecimalNumberInput"
                android:text="Clear Plain Text Input" />

            <!-- Button to assign number input to plain text input -->
            <Button
                android:id="@+id/AssignToPlainTextInput"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/ClearPlainTextInput"
                android:layout_below="@+id/ClearPlainTextInput"
                android:text="Assign Number Input to Plain Text Input" />

            <!-- Button to show plain text input -->
            <Button
                android:id="@+id/ShowPlainTextInput"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/AssignToPlainTextInput"
                android:layout_below="@+id/AssignToPlainTextInput"
                android:text="Show Plain Text Input" />
        </RelativeLayout>
    </ScrollView>

</RelativeLayout>

4.0 Download Source Code

You can get the source code by following the whole, well detailed and free tutorial above. But isn’t it more convenient if you can just download the complete source code we used, and play around it?

There’s a small fee in getting the complete source code, it is small compared to the:

✔ Value or skill upgrade it can bring you, or YES
✔ Income you can get from your website project or business. YES
✔ Precious time you save. YES

Buy now

Thanks a lot for your support and thanks for reading our Android EditText Example codes!

Android SharedPreferences Tutorial

Android SharedPreferences store private primitive data in key-value pairs. The data saved using SharedPreferences will still be available in the device even if your application is killed. Types of data that can be saved are booleans, floats, ints, longs, and strings. One use of Android SharedPreferences is to store data that can be used in different activity of your application.

Here’s the code:

package com.example.SharedPreferencesExample;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class SharedPreferencesExampleActivity extends Activity {
    /** Called when the activity is first created. */
   SharedPreferences settings;
  
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        try {
         //our edit text/text box where the name will be entered
         final EditText name_edit_text = (EditText) this.findViewById(R.id.NameTxt);
        
         //getSharedPreferences() – Use this if you need multiple preferences files identified by name, 
         //which you specify with the first parameter.
         //our preference name will be codeofaninja_shared_pref
         settings = getSharedPreferences(“codeofaninja_shared_pref”, 0);
        
            View.OnClickListener handler = new View.OnClickListener(){
                public void onClick(View v) {
                    switch (v.getId()) {

                        case R.id.SaveBtn:
                           //get entered value and set to a variable
                           String name_input = name_edit_text.getText().toString();
                            
                            //empty edit text field
                           name_edit_text.setText(“”);
                          
                           //SAVE shared pref value
                            SharedPreferences.Editor editor = settings.edit();
                            editor.putString(“name”, name_input);
                            editor.commit();
                            
                            //show button after saving
                            Toast.makeText(SharedPreferencesExampleActivity.this, 
                                       “You entered: “ + name_input,
                                       Toast.LENGTH_SHORT)
                                       .show();
                            
                            break;
                            
                        case R.id.ShowSavedBtn:

                           //RETRIEVE/load the saved shared pref value
                           String name = settings.getString(“name”, null);
                           Toast.makeText(SharedPreferencesExampleActivity.this, 
                                       “Saved Name is: “ + name, 
                                       Toast.LENGTH_LONG)
                                       .show();
                            break;
                    }
                }
            };
                
            //we will set the listeners
            findViewById(R.id.SaveBtn).setOnClickListener(handler);
            findViewById(R.id.ShowSavedBtn).setOnClickListener(handler);
                
        }catch(Exception e){
             Log.e(“SharedPreferences Example”, e.toString());
        } 
            
    }
}

Our XML Layout:

<?xml version=“1.0″ encoding=“utf-8″?>
<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”
   android:orientation=“vertical”
   android:layout_width=“fill_parent”
   android:layout_height=“fill_parent”
   >
    
   <EditText
   android:layout_width=“198dp”
   android:layout_height=“50sp”
   android:text=“” 
   android:id=“@+id/NameTxt”
   android:singleLine=“true”>
   </EditText>
 
    <Button
       android:id=“@+id/SaveBtn”
       android:layout_width=“198dp”
       android:layout_height=“wrap_content”
       android:text=“Save Name” >

    </Button>
    
    <Button
       android:id=“@+id/ShowSavedBtn”
       android:layout_width=“198dp”
       android:layout_height=“wrap_content”
       android:layout_alignRight=“@+id/SaveBtn”
       android:text=“Show Saved Name” >

    </Button>
    
</LinearLayout>

When you run this code:

Android SharedPreferences Tutorial

Entered something on the edit text:

SP-entered-name

Tapping “Save Name” button will clear the edit text and save the value on the SharedPreferences

SP-saved

Tapping “Show Saved Name” button, it will retrieve the saved value:

SP-show-saved

Just in case you want to download the code:

DOWNLOAD SOURCE CODE HERE

SharedPreferences Manager Class

Today I’m going to talk about how I manage Android SharedPreferences in my application. Not a long time ago, I posted about SharedPreferences, so you can take a look back if you don’t have any idea yet about SharedPreferences.
I basically used the setter and getter methods, which has been regarded as “evil” by many developers. I’m just a self thought programmer, I’m open to any suggestions by you guys especially if you are an advanced developer or knows a better implementation.
I feel convenient using this class, you can instantly write and read your SharedPreference values, especially if you choose to store several SharedPref values for your app. You just have to pass the context and then bam! You can use it even for a non-activity class.

How To Use?

Just the common way, instantiate:

 // make it a member variable
    SharedPreferencesManager SharedPrefMgr;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // create an instance
        SharedPrefMgr = new SharedPreferencesManager(this);
        
        // …

Write:

//just an example
String username = “ninjazhai”;
SharedPrefMgr.setUsername(username);

Read:

String curr_username = SharedPrefMgr.getUsername();

SharedPreferencesManager Class

Just an example of my SharefPreferencesManager Class.

import android.content.Context;
import android.content.SharedPreferences;
public class SharedPreferencesManager {

    Context mContext;

    SharedPreferences settings;
    SharedPreferences.Editor editor;

    public SharedPreferencesManager(Context mContext) {

        settings = mContext.getSharedPreferences(“my_shared_prefs”, 0);
        editor = settings.edit();

    }

    // —– firstname —–
    public String getFirstname() {
        return settings.getString(“firstname”, null);
    }

    public void setFirstname(String firstname) {
        editor.putString(“firstname”, firstname);
        editor.commit();
    }
    
    // —– lastname —–
    public String getLastname() {
        return settings.getString(“lastname”, null);
    }

    public void setLastname(String lastname) {
        editor.putString(“lastname”, lastname);
        editor.commit();
    }
    
    // —– username —–
    public String getUsername() {
        return settings.getString(“username”, null);
    }

    public void setUsername(String username) {
        editor.putString(“username”, username);
        editor.commit();
    }
    
    // —– folder name —–
    public String getFolderName() {
        return settings.getString(“folder_name”, null);
    }

    public void setFolderName(String folder_name) {
        editor.putString(“folder_name”, folder_name);
        editor.commit();
    }
    
    
    // —– debug mode —–
    public boolean getDebugMode() {
        return settings.getBoolean(“debug_mode”, false);
    }

    public void setDebugMode(boolean debug_mode) {
        editor.putBoolean(“debug_mode”, debug_mode);
        editor.commit();
    }
    
    // … you can add more here …
    
}

Install Android Development Environment on Ubuntu

Recently, I wanted to use Ubuntu 11.10 instead of Windows 7 for my Android application development. So far, I’m liking Ubuntu a lot, it is super fast, free, has great interface and animation, easy to learn and has lots of free applications that suits
my needs as a computer user and software developer. Now I’m thinking to be more of an Ubuntu Linux user than Windows user haha!

What is Ubuntu?

Ubuntu is a kind Linux Operating System that powers millions of net-books, desktops and servers all over the world. Using this amazing operating system is absolutely free of charge, and always will be. It is created and actively developed by the
best open source experts from all over the world. I think this is the only open source operating system that looks great. I find it stylish, beautiful and fast.

Anyway, enough of describing Ubuntu, this post is about Installing Android development environment in Ubuntu 11.10. Here are the links on how I was able
to successfully install my Android Development Environment on Ubuntu 11.10, these guides should be followed in order:

Install JDK 7 on ubuntu 11.10

Ubuntu Quick Tip: I just installed Java Development Kit (JDK) 7 on my newly installed Ubuntu 11.10 OS, yes, I’m gonna be using Ubuntu for my Android development stuff,
this is how I did it:

  1. Run the Terminal. You can do this by going to the Dash Home and search for “terminal”
  2. On the terminal, type:
  3.  sudo apt-get install openjdk-7-jdk
    
  4. The terminal will ask you to enter your admin password. After doing so, it will show you some data about what will be installed.
  5. It will ask you again if you want to continue, just type Y (for yes) and press enter.
  6. JKD download will start and…

Install Android Development Environment on Ubuntu

will be installed.

oie_211662TMfJiTJQ

Want to verify if Java was really installed? Here’s how.

Install Eclipse On Ubuntu

This post covers only how I was able to install Eclipse 3.7.0 IDE on Ubuntu 11.10. Eclipse IDE is used in most Android tutorials from Google, just like this Hello, World tutorial.

Click here if you want to view the complete links on how I completed installing my Android Development Environment on Ubuntu.

I did the following simple steps to install Eclipse IDE:

1.Run Ubuntu Software Center

Ubuntu-Software-Center

2.Search for “eclipse”

search-eclipse

The image above is the screen shot when Eclipse was installed already. But when you search for “Eclipse” and you don’t have Eclipse installed yet, you can see the Install Button (not remove button) at your screen, right across the Eclipse icon.

3.It will download Eclipse Indigo, Click Install Button
4.Wait while it downloads and apply changes (install)

Install Android Development Tools (ADT) on Ubuntu

Android Development Tools or ADT is a plugin for eclipse IDE that makes our life easier when developing Android applications. I think this is the reason why we highly recommend using Eclipse IDE during Android development.
See easy to understand and great ADT description on this lin. This post covers only how I was able to install ADT on Ubuntu 11.10. Click here if
you want to view the complete links on how I completed installing my Android Development Environment on Ubuntu.

I made it work by doing the following simple steps:

First Part:

  1. Open Eclipse
  2. Go to Help > Install New Software
  3. On the pop up, click Available Software Sites
  4. Tick http://download.eclipse.org/releases/helios
  5. Click OK
  6. On the “Work With” drop down, choose http://download.eclipse.org/releases/helios
  7. Please wait while it’s Pending
  8. helios-pending

  9. Then it will list the available tools
  10. On the list, tick Mobile and Device Development
  11. Click Next > Next > Read and Accept the Terms > Finish
  12. Wait for the software to be installed
  13. installing-software

  14. Click OK if security warning appears
  15. Restart Eclicpse

Second Part: When Eclipse was restarted.

  1. Go to help > install new software
  2. On the pop up Click Add
  3. On the prompt, enter:
  4. Name: Android ADT

    Location: http://dl-ssl.google.com/android/eclipse/

  5. Please wait for the Developer Tools to load while it is Pending
  6. Tick the Developer Tools then click the “Next” button
  7. Please wait while it loads
  8. Click Next > Read and Accept the terms > Finish
  9. Please wait while it install the software
  10. Click OK if security warning appears
  11. Restart Eclicpse

Hope this helps! Sorry for lack of screen shots (I actually hate doing lots of screen shots), I want you to believe in yourself that you can follow word instructions here even without pictures or screen shots, but if you have any questions or
suggestions, leave your comment on the comment section below. Thanks!

Install Android SDK on Ubuntu

Android Software Development Kit (SDK) enables developers to create Android applications. It includes sample source codes, device emulators, required libraries and tools to build Android applications for mobile devices. Click here if you want to view the complete links on how I completed installing my Android Development Environment on Ubuntu. This post covers only how I was able to install Android SDK on Ubuntu 11.10.

I made it work by doing the following simple steps:

Note: These steps should be performed after installing ADT and Eclipse was restarted.

1. Eclipse will prompt you to install Android SDK . Click Next

install-android-sdk-prompt

2. Choose Yes if you want to send usage statistics to Google

3. Click Finish

4. Wait for Android SDK manager while it loads

5. I choose accept all

6. Click Install

7. Please wait while it downloads

downloading-sdk

The steps above will install the latest SDK version, but if you want to install other SDK version, you can:

1. Run the Android SDK manager from eclipse

android-sdk-manager

2. It will load available SDK

android-sdk-manager

3. Tick your desired SDK version from the list

4. Click the Install button

5. Please wait while it downloads your selection

Proof

As a proof, I was able to run a HelloAndroid Application with the device emulator, here’s a screen shot:

hello-android-toast

Enjoy!

Verify if Java was Installed in Ubuntu 11.10

Ubuntu Quick Tip: After my JDK installation, I wanted to verify if it was really installed in my computer. Here’s how I verified it

1. Run your terminal.

2. Type:

          $ sudo updatedb
          $ locate java
  • It asked me to enter my password after typing sudo updatedb.
  • updatedb means you are updating the database for locate or locating your app.
  • locate finds files by name.
Verify if Java was Installed in Ubuntu 11.10
Click to enlarge.

3. If it returns something like this:

Click to enlarge.

it means JDK was installed.