Skip to main content

Posts

Showing posts from April, 2013

Android Layouts: Linear Layout, Relative Layout and Table Layout

In this post I will be discussing about the different view layouts in an android mobile application. The six different layouts are  1. Linear Layout 2. Relative Layout 3. Table Layout 4. Grid View 5. Tab Layout 6. List View Android allows you to create view layouts using simple XML file (we can also create a layout using java code). All the layouts must be placed in /res/layout folder. Okay, now lets get started with the view layouts. 1. Linear Layout In a linear layout, like the name suggests, all the elements are displayed in a linear fashion(below is an example of the linear layouts), either Horizontally or Vertically and this behavior is set in android:orientation which is an attribute of the node LinearLayout. Example of Vertical layout snippet < LinearLayout android:orientation = "vertical" > .... </ LinearLayout > Example of Horizontal layout snippet < LinearLayout android:orientation = &quo

Creating Your First Android Project

Eclipse will save all projects into a workspace directory. By default it creates a workspace directory called workspace in your home directory, but you can choose the workspace under File > Switch Workspace . I use this capability to create a workspace androidWorkspace in my home directory for all android projects, for example. If necessary, use File > Switch Workspace to choose the workspace you wish to use for the project. In default mode Eclipse will remember the workspace from your last session and start off there.  Create a New Project To create a new Android Project in Eclipse: Select File > New > Project . Select Android > Android Project , and click Next (after you do this once you will have the future option of the shortcut File > New > Android Project ). Specify the contents for the project: Project Name: name of the subdirectory in the workspace directory where your project will be created. Example: MyApp . Then if

About the Android Manifest.xml File

  The main element is not surprisingly the manifest element.  It has attributes to specify : Android namespace schema url ( “ http://schemas.android.com/apk/res/android ”) Base package name for the android application. This serves two purposes: Uniquely identifies the application on a device.   Your website url would be a good choice. eg:   yourwebsite.com.package.suffix Acts as a shortcut for dot (“.”) that can used to specify  the class names elsewhere in the manifest file. For eg, “ . MainActivity” instead of com.example . MainActivity in the example shown here. Android manifest version code is an integer that is used to identify the version of your application. Newer versions are expected to have a higher version code than the older ones and is  used in deciding whether to update your application with a new version. The minsdkversion element indicates the minimum api level supported by your android application. For example if  you are using the api

Android Project structure

/bin: Contains the compiled java class (.class) files, the dalvik executables (.dex) files etc /gen: Contains the files generated by the android build tools (eg: R.java) /lib: Contains third party libraries (jars) used by the application. /res: Contains resources used by the application like icons, layouts, localized strings etc. Android build tools generate Ids (in the R.java file)  for each resource placed inside the resource folder. Contains the following sub folders, /res/drawable: Contains images with further subfolders for high-density/medium-density and low-density screens. /res/layout: Contains xml files representing the UI layouts of your application. /res/menu: Contains xml files representing the application menus. /res/values: Contains xml files representing externalized strings, colors, styles, dimensions etc. /res/xml: Contains additional xml files need by the application /res/color: Contains additional color resources that adapt to view states /res/raw: Ot

What is DDMS & How it works?

Android provides a debugging tool called the Dalvik Debug Monitor Server (DDMS). I) what is the advantages of DDMS? II) How DDMS works? I) Advantages of DDMS: i) DDMS provides port-forwarding services. ii) Screen capture on the device. iii) Thread and heap information on the device. iv) Logcat. v) Process. vi) Radio state information. vii) Incoming call and SMS spoofing, location data spoofing, and more. II) How DDMS works : To use DDMS open the perspective DDMS : go to Window->Open Perspective->Other, DDMS Devices: In the top left corner we can see a tab “Devices”. There we can get the list of devices and emulator which are on line (for more understanding see the below picture). Below each instance of the Emulator or device, we have all processes that are running in this instance. From left to right we will see some icons: I) Bug: This shows you the debugger state. If it is green that means we are con