Tuesday, April 16, 2013

Android App Development with Eclipse Android Perspective

Android Development Kit and Eclipse IDE both freewares are just what you need to develop Apps with Android.

Here is the information for getting Android SDK.

Start a new Android Application Project.

In this dialog you can specify the platform target Android Platform.


In the Configure Project dialog you can specify the Location of the project.

In Configure Launcher Icon dialog you can specify the icon for the App. You can see multiple icons in the preview section which corresponds to different resolution version of the app like High dpi, Low dpi, etc. So there will be different dpi (Dotes per inch) files stored inside folder inside res folder like drawable-hdpi, drawable-ldpi, etc.

It is possible to select another picture to act as the icon for you app.


 I am selecting the flight icon.


Activity

An Activity in Android roughly corresponds to a various screens in your application. 


An activity is going to be represented by a Java class.

The layout file specifies the layout of the screen. It is an xml  file located inside layout folder inside res folder.   It is not recommended to edit the generated xml file instead use the familar IDE options to work with layout files. 
Android applicable comprises of a complex folder pattern.
Android comes with a lot of  controls for creating rich applications.

Strings
Strings is yet another xml file that contains the strings user in the application.  


Since I have edited the app name in the String xml file you can see the difference reflected in the application


Emulator
Android comes with an emulator which can be used for testing the application. 



You can create a  button  by dragging and dropping a button from the Form Widgets.


Java
Java is the language for Android.


Here I am trying to create  an object of Button. Since the  import statement  android.widget.Button is missing I am getting an error indication. 


On clicking the error icon a dialog will popup from where you can select the required import statement. So you need not remember the import statements.  Alternatively you can press Ctl+Shift+O. Remember in Visual Studio .Net it is Ctrl+.(Dot).


R File

R File placed inside the gen folder is the glue between .java file and the resource file.



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_fullscreen);
        
    btn = (Button)findViewById(R.id.dummy_button);
    btn.setOnClickListener(new OnClickListener() {
            
         @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Toast.makeText(FullscreenActivity.this, "Hello Android", Toast.LENGTH_LONG).show();
            btn.setText("Shalvin");
        }
    });

Here I am creating an OnClick listener to display a Toast.


4 comments:

  1. Excellent ! it is very useful post.
    More detail

    ReplyDelete
  2. Thanks for sharing the quick smart tutorial with us. Its very useful in android apps development

    ReplyDelete
  3. I am truly cheerful to find this website. I’d like to thank you so much for this excellent reading.

    Hire Android Developers

    ReplyDelete