We can either draw directly on a Canvas object or to modify existing Views to customise their look and feel. Drawing is performed in the onDraw() method. Simple graphics can be created in the layout XML file too. We use the Canvas object to perform drawing. A Canvas is an object that has drawing methods to do theContinue Reading

A dialog is defined as a conversation between two or more persons. In a computer application a dialog is a window which is used to “talk” to the application. A dialog is used to input data, modify data, change the application settings etc. An AlertDialog is a dialog used to display informationContinue Reading

There are three kinds of menus in Android: options menu, context menu, and popup menu. The options menu is the primary collection of menu items for an activity. In the options menu we should have commands that have global impact on the applications. For example a Settings menu. It is displayed eitherContinue Reading

There are number, date or time pickers. NumberPicker NumberPicker is a widget that allows us to select a number from a predefined range of values. The manifest file is not modified in this example. main.xml <?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” > <NumberPicker android:id=”@+id/npId” android:layout_marginTop=”5dp” android:layout_width=”wrap_content” android:layout_height=”wrap_content” /> <TextViewContinue Reading

A ListView is a widget that shows items in a vertical scrolling list. An Adapter object is used to fill the ListView with data. ListView Widget I In the example, we show a ListView widget with the names of the planets of our solar system. We use an ArrayAdapter to fill the ListView with data. main.xml <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical”Continue Reading

ProgressBar I We have a horizontal ProgressBar widget and a TextView widget that shows the percentage of the task completed. The manifest file is left untouched. main.xml <?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” > <ProgressBar android:id=”@+id/pbId” android:layout_width=”fill_parent” android:layout_height=”wrap_content” style=”?android:attr/progressBarStyleHorizontal” android:layout_margin=”10dp” /> <TextView android:id=”@+id/tvId” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:layout_margin=”10dp” /> </LinearLayout> In the main.xml layout file, weContinue Reading

The SeekBar widget is used to select a value from a range of values. The user drags a thumb of the widget to select a specific value. To process the SeekBar events, we implement the SeekBar.OnSeekBarChangeListener listener. SeekBar example We have a SeekBar widget and a TextView widget. The current value from the SeekBar is displayed in the TextView. Android manifest file isContinue Reading

A spinner widget enables a user to select an item from a list of options. In the normal state it shows the currently selected item. Clicking on the spinner widget shows a dropdown menu with all available items. The user can choose a new one from the list. The Spinner class isContinue Reading

When we design the user interface of our application, we decide what components we will use and how we will organise those components in the application. To organise our components, we use specialised non visible objects called layout managers. There are several layout managers in Android. A LinearLayout lines up its viewsContinue Reading

According to the Android developer documentation, an Intent is an asynchronous message. It is an abstract description of an operation to be performed. Intents are used to navigate through activities. Activities, services and broadcast receivers are activated through intents. Intents enable loose coupling of code in the application. An Intent is passed to theContinue Reading