Pages

Monday, October 1, 2012

GUI part

In previous post i have told about the files in android project..

Now i m concerning about the GUI part means the various layouts used in application development :


The first question arises from layout is: 

What Is A Layout?

Android developers use the term layout to mean one of two things. Both definitions apply to this tutorial, and are, unfortunately used interchangeably in the Android development community. The two definitions of layout are:
  • A type of resource that defines what is drawn on the screen. Layout resources are stored as XML files in the /res/layout resource directory for the application. A layout resource is simply a template for a user interface screen, or portion of a screen, and contain.
  • A type of View class whose primary purpose is to organize other controls. These layout classes (LinearLayout, RelativeLayout, TableLayout, etc. ) are used to display child controls, such as text controls or buttons or images on the screen.
Android user interfaces can be defined as layout resources in XML or created programmatically.

Because we are using Eclipse IDE so,

      Using Eclipse to Design Layout Resources

The Android Development Plug-in for Eclipse includes a handy layout resource designer for designing and previewing layout resources. The tool includes two tab views: the Layout view allows you to preview how the controls will appear on various screens and for each orientation and the XML view shows you the XML definition of the resource. The layout resource designer is shown in this figure:


Here are some tips for working with the layout resource designer in Eclipse:
  • Use the Outline pane to Add and Remove controls to your layout resource.
  • Select a specific control (either in the Preview or the Outline) and use the Property pane to adjust a specific control’s attributes.
  • Use the XML tab to edit the XML definition directly.
It’s important to remember that the Eclipse layout resource designer preview can’t replicate exactly how the layout will appear to end users. For this, you must test your application on a properly configured emulator and, more importantly, on your target devices. Also, certain “complex” controls, including tabs or video viewers, cannot be previewed within Eclipse.

Defining an XML Layout Resource :


The most convenient and maintainable way to design application user interfaces is by creating XML layout resources. This method greatly simplifies the UI design process, moving much of the static creation and layout of user interface controls and definition of control attributes, to the XML, instead of littering the code. It creates a potential distinction between UI designers (who concern themselves more with layout) and developers (who know Java and implement application functionality). Developers can still alter the content of a screen programmatically when necessary. Complex controls, like ListView or GridView, are usually populated with data programmatically.
XML layout resources must be stored in the /res/layout project directory (or, in the case of alternative resources, in a specially named sub-directory). It’s common practice to create an XML layout resource for each screen in your application (closely tied to a specific Activity), but this is not required. You could, in theory, create an XML layout resource and use it for different activities, supplying different data on the screen. You can also componentized your layout resources and include them within one another, if needed.
The following is a simple XML layout resource, a template with a LinearLayout containing a TextView and an ImageView, defined in XML:

    Place this code in your main.xml file:
     and paste a pic in drawable folder name it as matterhorn....
                                     
<?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"  
    android:gravity="center">  
    <TextView  
        android:layout_width="fill_parent"  
        android:id="@+id/PhotoLabel"  
        android:layout_height="wrap_content"  
        android:text="This is photo of the Matterhorn"  
        android:gravity="center_horizontal"  
        android:textSize="20dp" />  
    <ImageView  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:src="@drawable/matterhorn"  
        android:adjustViewBounds="true"  
        android:scaleType="fitXY"  
        android:maxHeight="250dp"  
        android:maxWidth="250dp"  
        android:id="@+id/Photo" />  
</LinearLayout>  

This layout represents a simple screen with two controls: first some text and then an image below it. These controls are organized within a vertically oriented LinearLayout. The following two figures show what this layout might look like on a device in both portrait and landscape modes:
Vertical View

Horizontal View



Exploring Various Layout Types

Now let’s turn our attention to those helpful layout controls that organize other controls. The most commonly used layout classes are:

  • FrameLayout – designed to display a stack of child View controls. Multiple view controls can be added to this layout. This can be used to show multiple controls within the same screen space.

  • LinearLayout – designed to display child View controls in a single row or column. This is a very handy layout method for creating forms.

  • RelativeLayout – designed to display child View controls in relation to each other. For instance, you can set a control to be positioned “above” or “below” or “to the left of” or “to the right of” another control, referred to by its unique identifier. You can also align child View controls relative to the parent edges.



  • TableLayout – designed to organize child View controls into rows and columns. Individual View controls are added within each row of the table using a TableRow layout View (which is basically a horizontally oriented LinearLayout) for each row of the table.


On next i will tell how to make GUI more Attractive..................

Tuesday, September 25, 2012

Unknown Facts

Android Unknown Facts:

If you thought Android was the brainchild of Google, think again. It was devised way back in 2003 by Andy Rubin and Rich Miner only to sell it to Google for $50 million. Google put the concept in cold storage until 2007 when it announced plans to launch the Android mobile platform. Today Rubin is the director of mobile platforms and Miner the group manager, both at Google.

AndroidManifest.xml

The AndroidManifest.xml File :

 Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code. Among other things, the manifest does the following:
  • It names the Java package for the application. The package name serves as a unique identifier for the application.
  • It describes the components of the application — the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities (for example, which Intent messages they can handle). These declarations let the Android system know what the components are and under what conditions they can be launched.
  • It determines which processes will host application components.
  • It declares which permissions the application must have in order to access protected parts of the API and interact with other applications.
  • It also declares the permissions that others are required to have in order to interact with the application's components.
  • It lists the Instrumentation classes that provide profiling and other information as the application is running. These declarations are present in the manifest only while the application is being developed and tested; they're removed before the application is published.
  • It declares the minimum level of the Android API that the application requires.
  • It lists the libraries that the application must be linked against.

Unknown Facts

Android Unknown Facts

Android is the latest mobile OS to hit the market with lots of amazing features and promoted by a group of more than 30 renowned companies led by no less than Google itself. Still are you aware of all the Android facts other than its cute logo and geek name, probably not. So here we bring out the lesser-known Android facts that are sure to catch your interest in this superb mobile platform.
5 Things You Never Knew About Android:
  1. If you thought Android was the brainchild of Google, think again. It was devised way back in 2003 by Andy Rubin and Rich Miner only to sell it to Google for $50 million. Google put the concept in cold storage until 2007 when it announced plans to launch the Android mobile platform. Today Rubin is the director of mobile platforms and Miner the group manager, both at Google.
     
  2. Android is based on Linux, the open source operating system and Windows challenger. And if anything challenges Microsoft it interests Google. Apart from this keeping Android source code open means many developers will be attracted to the development environ and will also help to keep the costs down and revenues high.
      
  3. While the iPhone can only run one app at a time the Android is a proper multi-tasking mobile OS that can run multiple apps like the Google Maps, media player, browser at the same time without any hiccups. Seems like iPhone has some catching up to do at least in one department.
      
  4. Will Android be completely open as previously thought? It seems not and a good reason for saying this is the fact that the complete Android code hasn't been disclosed to the developer community and it is likely that Google will not disclose the crux of the Android code for reasons best known to it. Be ready for less than full Android development then.
       
  5. You must be wondering hoe does Google benefit from keeping the Android platform open source especially when it doesn't take a dime from the application distributed through the online Android Market. Well Google the old hat wants to dominate the mobile advertising space just like it has dominated the PC web space. So don't be surprised if you see a pop up every now and then while browsing on your Android phone, after all Google doesn't collect the huge chunk of your personal browsing data for nothing, does it?

Sunday, September 23, 2012

Files in an android application

Now its time to get the knowledge about all the files in an android application which build automatically while making a android project.


when we create a android project a number of files are built in the project these files are........
1.) src -: this file is the functional file of any project which is based on the java language.here we create the java file for the specific purpose and code them according to our need.
2.) gen -: this file is the auto generated and auto modifiable file. this file should not be modified.this file contains a java file named R.java which contains all the registry about the projects like the GUI items like buttons, images etc.
3.) android library -: this is the library file need not to do anything with it. creation of this file is depended on the android target you used while making a new project.
4.) assets -: this files contains the extra material or stuffs like fonts ,colors etc.
5.) bin -: in this file the executable file been saved which is executable in android platform the extention of this file is "application name.apk".
6.) res -: here the designing part is being coded. Means the GUI is made in this file.this file has some more sub files which are.
    a.) drawable-hdpi-: containa the images with high quality
    b.) drawable-mdpi-: containa the images with medium quality
    c.) drawable-ldpi-: containa the images with low quality
    d.) layouts-: layouts are the graphical interface desined for application which is made for user
          to interact with application
    e.) values-: it contains the strings which we write anywhere in our application.
7.) AndroidManifest.xml -: this file is responsible for the services which we used in the android device like the camera,flash,vibrate etc. all the java files must be declared in this file to make them execute normally and successfully.
8.) proguard.cfg -: this file is auto generated and keep the java and android services. Need not to do anything with it.
9.) project.properties -: properties file of the project auto modifiable dont touch until get any error.

Thursday, September 13, 2012

Eclipse and SDK Downloading links

LINKS for Eclipse and SDK...

 Hey I forgot to give the links to download Eclipse and SDK...........
Here is the links.
Eclipse : www.eclipse.org/downloads/index.php
SDK : https://developer.palm.com/content/resources/develop/sdk_pdk_download.html

Dont forget that you have to install the java jdk on your System...

Monday, September 10, 2012

First Andoid Application.

In my first post I have posted how to install android platform.



Now lets move towards the first andoid application.
We will start with a simple android application which will show a screen printed "Hello World, AndroidActivity!".
Now open file in file open new android project.
once you click in new android project the screen will open like it rest i will tell in the screens.



when you click on next a window will open in which you have to write the desired application name then the package name  basically package name is devided into three parts and seperated with the dots(.) where the your is written in the window place com there then any desired text like your name ,company name then after . and then the application name.
suppose i am making a new project with name hello and my name is nik and application name is AndroiD. then i will ceate package like "com.nik.AndroiD".
then the activity which is a default auto generated class name whatever you want and the minimum sdk version will be placed there automatically according to what target you have selected for the project.

and click on Finish button.
On clicking finish you will see a window in which you have a project named hello just explore that project and you will see various folders and files.i am showing you below.


When you see these files then time to check that if the applcation is running or not.
First make a simulator means virtual platform to run the applications for that click on window then AVD manager.


In AVD manager you will see the window where you have to create a Enumelator


give a name to avd and select target according to project target.then click on create avd.

Once you have created the AVD you have to run the application
for that just right click on the hello project then go to "Run As" and click on the Run Configurations....


now you will see the window like below.



1.click on Android Application
2.click on Target
3.click on checkbox which enumelator you want to launch
4.click on run.
after clicking on run a enumeltor will open like below.

dont make any change in the application till the enumelator starts.Once it starts it will look like an android mobile on your system.




Simply unlock it and here is the output of the Application.





later i will tell about each file and folder of the project in brief.



Starting with Android.

Android Tutorial:


           For android development first you need an GUI interface to code because for an android project all the files should have to be in its proper place to create a android executable file (.apk file).

So for developing you have to download the ECLIPSE ,the latest version of eclipse will be good.Eclipse will be of size approximate 300-400MB.

and you have to download the sdk kit to make support to android.This will of size approx 2-3GB

eclipse an sdk will be in a zip file you only have to extract it on your desired location need not to install it.

You can download it from these links.

 Once you have extract it and will run the eclipse it will look like the pic below.

 The green bar shows the progress of opening the eclipse. After the progress complete a window will open like this.


The links on welcome like screen OVERVIEW, SAMPLE, TUTORIAL will be tough to understand if you don't have any knowledge about android. you just have to click on the link Workspace which is circled in the above window.

After opening Workbench you will see a window divided in several parts.

 After opening the workspace click on windows then click on preference.

After clicking on preference you will see the following window. and click on android and then click on browse.


after clicking on browse a popup window will open and from there select the path of the sdk where you have extracted the sdk. finally press ok.


Now you are ready to make Android Application.