Posts

Showing posts from 2014

ListView

Image
Android  ListView  is a view which groups several items and display them in vertical scrollable list. The list items are automatically inserted to the list using an  Adapter  that pulls content from a source such as an array or database. An adapter actually bridges between UI components and the data source that fill data into UI Component. Adapter can be used to supply the data to like spinner, list view, grid view etc. Consider you have an array of strings you want to display in a ListView, initialize a new  ArrayAdapter. ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.listview, StringArray);             Here are arguments for this constructor: First argument is the application context. Most of cases, use this. Second argument layout defines in XML file, having TextView for each string in the array. Final argument is the array of strings which will be shown as a list. O...

Table Layout

Image
Android TableLayout groups views into rows and columns. You will use the <TableRow> element to build a row in the table. Each row has zero or more cells; each cell can hold one View object. TableLayout containers do not display border lines for their rows, columns, or cells. Important Attributes for the Table Layout: Attribute Description android:id This is the ID which uniquely identifies the layout. android:collapseColumns This specifies the zero-based index of the columns to collapse. The column indices must be separated by a comma: 1,2,5 android:stretchColumns The zero-based index of the columns to stretch. The column indices must be separated by comma: 1,2,5 android:shrinkColumns The zero-based index of the columns to shrink. The column indices must be separated by comma: 1,2,5 For example, following is the content of  activity_main.xml  containing Table Layout: ...

Progress Bar

Image
We can display the progress bar dialog box to display the status of work being done like Downloading file, Loading page, etc. In this example, we are displaying the progress dialog for dummy file download. The ProgressDialog class provides methods to work on progress bar like setProgress(), setMessage(), show() etc. activity_main.xml <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"     tools:context=".MainActivity" >     <Button         android:id="@+id/button1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignParentLeft="true"  ...
Image

Virtual Machine VM

VM acts as a hardware for performing operations. VM can be divided into two categories based on its working and functionality: System Virtual Machine Process Virtual Machiine Based on its architecture VMs are divided into: Stack based VM Register based VM System VM vs Process VM The System VM simulates the complete system hardware stack and supports the execution of complete operating system. On the other hand, Process VM adds up layer over an operating system which is use to simulate the programming environment for the execution of the individual process. The Process VM is created when process begins and it ends when process gets terminated. The main purpose of process VM is to provide platform independency. JVM and CLR (Common Language Runtime) are examples of Process VM. Stack based vs Register based VM A register VM is likely to have an intrinsic performance advantage over a stack based VM. Byte code verification is likely to be faster on a register VM because...

Frame Layout

Image
Frame Layout is designed to block out an area on the screen to display a single item. Generally this layout should be used to hold a single child view, because it can be difficult to position different child views in same layout. You can add multilple chlidren to Frame Layout and control their positions within the Frame Layout by assigning gravity to each field, using the android:layout_gravity attribute. Important attributes of Frame Layout: Attribute Description android:id This is the ID which uniquely identifies the layout. android:foreground This specifies the the drawable to draw over the content and possible values may   be a color value, in the form of #rgb, #argb, #rrggbb or #aarrggbb. android:foregroundGravity Defines the gravity to apply the foreground drawable. The gravity defaults to fill. Possible values are top, bottom, left, center, right, center_vertical, center_horizontal etc. Android:meas...