You are on page 1of 39

Android Application Development Training Tutorial

For more info visit http://www.zybotech.in

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Views
The basic unit of the Android UI is the View. A View represents a widget that has an appearance on the screen. Categorized the views in this series into the following group:

Basic Views - commonly-used views such as TextView, EditText, and Button views Picker Views - views that allows users to select from, such as the TimePicker and DatePicker views List Views - views that display a long list of items, such as the ListView and the Spinner views Display Views - views that display images, such as the Gallery and ImageSwitcher views Menus - views that displays additional and context sensitive menu items Additional Views - interesting views such as the AnalogClock and DigitalClock views

1. Basic Views
The basic views in Android that allow you to display text information as well as perform some basic selection. In particular, you will learn about the following views:

TextView EditText Button ImageButton CheckBox ToggleButton RadioButton RadioGroup

TextView View When you create a new Android project, Eclipse always creates the main.xml file (located in the res/layout folder) containing a <TextView> element: <?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" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout> The TextView view is used to display text to the user. This is the most basic view that you will definitely come across when you develop Android applications. If you need to allow users to edit the text displayed, you should
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

use the subclass of TextView EditText. Button, ImageButton, EditText, CheckBox, ToggleButton, RadioButton, and RadioGroup Views Besides the TextView view, which you will come across the most often, there are some other basic controls that you will find yourself using very often. They are: Button, ImageButton, EditText, CheckBox, ToggleButton, RadioButton, and RadioGroup. First, add a new file to the res/layout folder and name it as basicviews.xml. Populate it with the following elements: <?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" > <Button android:id="@+id/btnSave" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Save" /> <Button android:id="@+id/btnOpen" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Open" /> <ImageButton android:id="@+id/btnImg1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:src="@drawable/icon" /> <EditText android:id="@+id/txtName" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <CheckBox android:id="@+id/chkAutosave" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Autosave" /> <CheckBox android:id="@+id/star" style="?android:attr/starStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <RadioGroup android:id="@+id/rdbGp1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" >
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

<RadioButton android:id="@+id/rdb1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Option 1" /> <RadioButton android:id="@+id/rdb2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Option 2" /> </RadioGroup> <ToggleButton android:id="@+id/toggle1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> Note that you use the id attribute to identify each view. The id of a view must start with the "@+id/" specifier followed by the name of the view. The above XML file contains the following views:

Button - represents a push-button widget ImageButton - similar to the Button view, except that it also displays an image EditText - a subclass of the TextView view, except that it allows users to edit its text content CheckBox - a special type of button that has two states - checked or unchecked RadioGroup and RadioButton - the RadioButton has two states - either checked or unchecked. Once a RadioButton is checked, it cannot be unchecked. A RadioGroup is used to group together one or more RadioButton views, thereby allowing only one RadioButton to be checked within the RadioGroup ToggleButton - displays checked/unchecked states using a light indicator

Examples of Basic Views:

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Output of Basic Views

2. Picker Views
Selecting date and time is one of the very common tasks you need to perform in a mobile application. Android supports this functionality through the TimePicker and DatePicker views. TimePicker and DatePicker View The TimePicker view allows users to select a time of the day, in either 24 hour mode or AM/PM mode. Add a new file to the res/layout folder and name it as dateandtimepicker.xml and populate it with the following element: <?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" > <TimePicker android:layout_width="wrap_content" android:layout_height="wrap_content" />
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

<DatePicker android:layout_width="wrap_content" android:layout_height="wrap_content" />

</LinearLayout>

Add a new class to the src folder and name it as DateTimePickerExample.java. Populate it as follows:

import android.app.Activity; import android.os.Bundle; public class DateTimePickerExample extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.datetimepicker); } }
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Output of Picker Views

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

3. List Views
The ListView and Spinner views are useful for displaying long lists of items. ListView View The ListView view displays a list of items in a vertically scrolling list. Add a new file to the res/layout folder and name it as listview.xml and populate it with the following element: <?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" > <ListView android:id="@+id/android:list" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout>

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Add a new class to the src/net.learn2develop.AndroidViews folder and name it as ListViewExample.java. Populate it as follows: import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import android.app.ListActivity; public class ListViewExample extends ListActivity { String[] presidents = { "Dwight D. Eisenhower", "John F. Kennedy", "Lyndon B. Johnson", "Richard Nixon", "Gerald Ford", "Jimmy Carter", "Ronald Reagan", "George H. W. Bush", "Bill Clinton", "George W. Bush", "Barack Obama" };
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listview); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, presidents)); } public void onListItemClick( ListView parent, View v, int position, long id) { Toast.makeText(this, "You have selected " + presidents[position], Toast.LENGTH_SHORT).show(); } }

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Output of ListView:

Spinner View The Spinner view displays an item at a time from a list and lets the users choose among them. Add a new file to the res/layout folder and name it as spinner.xml and populate it with the following element: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

android:layout_width="fill_parent" android:layout_height="fill_parent" > <Spinner android:id="@+id/spinner1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawSelectorOnTop="true" /> </LinearLayout>

Add a new class to the src folder and name it as SpinnerExample.java. Populate it as follows:

import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.Toast; import android.widget.AdapterView.OnItemSelectedListener; public class SpinnerExample extends Activity {
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

String[] presidents = { "Dwight D. Eisenhower", "John F. Kennedy", "Lyndon B. Johnson", "Richard Nixon", "Gerald Ford", "Jimmy Carter", "Ronald Reagan", "George H. W. Bush", "Bill Clinton", "George W. Bush", "Barack Obama" }; Spinner s1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.spinner); s1 = (Spinner) findViewById(R.id.spinner1); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, presidents); s1.setAdapter(adapter); s1.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { int index = s1.getSelectedItemPosition(); Toast.makeText(getBaseContext(), "You have selected item : " + presidents[index], Toast.LENGTH_SHORT).show(); } public void onNothingSelected(AdapterView<?> arg0) {} }); } }

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Output of SpinnerView:

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

The above program creates an ArrayAdapter object and associates it with the Spinner view. When an item in the Spinner view is selected, you will use the Toast class to display the item selected.

4. Display Views
So far all the views you have seen are used to display text information. For displaying images, you can use the ImageView, Gallery and ImageSwitcher views. Gallery and ImageView Views The Gallery is a view that shows items (such as images) in a center-locked, horizontal scrolling list. To see how the Gallery view works, add a new file to the res/layout folder and name it as displayview.xml and populate it with the following elements: <?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" > <TextView android:layout_width="fill_parent"
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

android:layout_height="wrap_content" android:text="Images of San Francisco" /> <Gallery android:id="@+id/gallery1" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <ImageView android:id="@+id/image1" android:layout_width="320px" android:layout_height="250px" android:scaleType="fitXY" /> </LinearLayout>

Add a new file to the res/values folder and name it as attrs.xml. Populate it with the following: <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="Gallery1"> <attr name="android:galleryItemBackground" /> </declare-styleable> </resources> Add a new class to the src folder and name it as DisplayViewsExample.java. Populate it as follows:
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

import android.app.Activity; import android.content.Context; import android.content.res.TypedArray; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Gallery; import android.widget.ImageView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; public class DisplayViewsExample extends Activity { //---the images to display--Integer[] imageIDs = { R.drawable.pic1, R.drawable.pic2, R.drawable.pic3, R.drawable.pic4, R.drawable.pic5, R.drawable.pic6, R.drawable.pic7 }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.displayview); Gallery gallery = (Gallery) findViewById(R.id.gallery1); gallery.setAdapter(new ImageAdapter(this)); gallery.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { Toast.makeText(getBaseContext(), "pic" + (position + 1) + " selected", Toast.LENGTH_SHORT).show(); } }); } public class ImageAdapter extends BaseAdapter {
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

private Context context; private int itemBackground; public ImageAdapter(Context c) { context = c; //---setting the style--TypedArray a = obtainStyledAttributes(R.styleable.Gallery1); itemBackground = a.getResourceId( R.styleable.Gallery1_android_galleryItemBackground, 0); a.recycle(); } //---returns the number of images--public int getCount() { return imageIDs.length; } //---returns the ID of an item--public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } //---returns an ImageView view--public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView = new ImageView(context); imageView.setImageResource(imageIDs[position]); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setLayoutParams(new Gallery.LayoutParams(150, 120)); imageView.setBackgroundResource(itemBackground); return imageView; } } }

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Output of DisplayViews:

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

You create the ImageAdapter class (which extends the BaseAdapter class) so that it can bind to the Gallery view with a series of ImageView views. The ImageView view is used to display images. When an image in the Gallery view is selected (or clicked), the position of the image selected is displayed. If you want to display the selected image in an ImageView view, modify the onItemClick() method so that the selected image is shown in the ImageView (image1) view: public void onItemClick(AdapterView parent, View v, int position, long id) { //---display the images selected--ImageView imageView = (ImageView) findViewById(R.id.image1); imageView.setImageResource(imageIDs[position]);

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

ImageSwitcher View You saw in the previous section on how to use the Gallery view together with an ImageView view to display a series of thumbnail images so that when one is selected, the selected image is displayed in the ImageView view. Because this is such a common UI task, Android provides the ImageSwitcher view, which is functionally similar to what you have achieved in the previous section. Modify the displayview.xml file as follows by adding the ImageSwitcher element: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ff000000" > <ImageSwitcher android:id="@+id/switcher1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentBottom="true"
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

/> <Gallery android:id="@+id/gallery1" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </RelativeLayout>

Modify the DisplayViewsExample.java file as shown below: import android.app.Activity; import android.content.Context; import android.content.res.TypedArray; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.view.animation.AnimationUtils; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Gallery; import android.widget.Gallery.LayoutParams; import android.widget.ViewSwitcher.ViewFactory; import android.widget.ImageSwitcher; import android.widget.ImageView; import android.widget.AdapterView.OnItemClickListener;
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

public class DisplayViewsExample extends Activity implements ViewFactory { //---the images to display--Integer[] imageIDs = { R.drawable.pic1, R.drawable.pic2, R.drawable.pic3, R.drawable.pic4, R.drawable.pic5, R.drawable.pic6, R.drawable.pic7 }; private ImageSwitcher imageSwitcher; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.displayview); imageSwitcher = (ImageSwitcher) findViewById(R.id.switcher1); imageSwitcher.setFactory(this); imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in)); imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out)); Gallery gallery = (Gallery) findViewById(R.id.gallery1); gallery.setAdapter(new ImageAdapter(this)); gallery.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { imageSwitcher.setImageResource(imageIDs[position]); } }); } public View makeView() { ImageView imageView = new ImageView(this); imageView.setBackgroundColor(0xFF000000); imageView.setScaleType(ImageView.ScaleType.FIT_CENTER); imageView.setLayoutParams(new ImageSwitcher.LayoutParams( LayoutParams.FILL_PARENT,
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

LayoutParams.FILL_PARENT)); return imageView; } public class ImageAdapter extends BaseAdapter { private Context context; private int itemBackground; public ImageAdapter(Context c) { context = c; //---setting the style--TypedArray a = obtainStyledAttributes(R.styleable.Gallery1); itemBackground = a.getResourceId( R.styleable.Gallery1_android_galleryItemBackground, 0); a.recycle(); } //---returns the number of images--public int getCount() { return imageIDs.length; } //---returns the ID of an item--public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } //---returns an ImageView view--public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView = new ImageView(context); imageView.setImageResource(imageIDs[position]); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setLayoutParams(new Gallery.LayoutParams(150, 120)); imageView.setBackgroundResource(itemBackground); return imageView; } } }

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Output of ImageSwitcherView:

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Observe that the DisplayViewsExample class now implements the ViewFactory class. The ViewFactory class creates the views in a ViewSwitcher view. When your class implements the ViewFactory class, you need to override the makeView() method, which creates a new View to be added in a ViewSwitcher. GridView View The GridView view shows items in two-dimensional scrolling grid. You can use the GridView view together with ImageView views to display a series of images. Modify the displayview.xml file as follows: <?xml version="1.0" encoding="utf-8"?> <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:numColumns="auto_fit" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:columnWidth="90dp" android:stretchMode="columnWidth" android:gravity="center" />
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

In the DisplayViewsExample.java file, code the following:

import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; public class DisplayViewsExample extends Activity { //---the images to display--Integer[] imageIDs = { R.drawable.pic1, R.drawable.pic2, R.drawable.pic3, R.drawable.pic4, R.drawable.pic5,
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

R.drawable.pic6, R.drawable.pic7 }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.displayview); GridView gridView = (GridView) findViewById(R.id.gridview); gridView.setAdapter(new ImageAdapter(this)); gridView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { Toast.makeText(getBaseContext(), "pic" + (position + 1) + " selected", Toast.LENGTH_SHORT).show(); } }); } public class ImageAdapter extends BaseAdapter { private Context context; public ImageAdapter(Context c) { context = c; } //---returns the number of images--public int getCount() { return imageIDs.length; } //---returns the ID of an item--public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } //---returns an ImageView view--public View getView(int position, View convertView, ViewGroup parent)
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

{ ImageView imageView; if (convertView == null) { imageView = new ImageView(context); imageView.setLayoutParams(new GridView.LayoutParams(85, 85)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(5, 5, 5, 5); } else { imageView = (ImageView) convertView; } imageView.setImageResource(imageIDs[position]); return imageView; } } }

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Output of GridView:

Observe that the code is very similar to the Gallery view example - you create the ImageAdapter class (which extends the BaseAdapter class) so that it can bind to the GridView view with a series of ImageView views. The ImageView view is used to display images. When an image is selected, the position of the image is displayed using the Toast class.

5. Additional Views
the Android SDK also provides some interesting views that make your applications much more interesting. In the following sections, you will learn more about the following views:
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

AnalogClock DigitalClock WebView

AnalogClock and DigitalClock Views The AnalogClock view displays an analog clock. Populate the main.xml file with the following element: <?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" > <AnalogClock android:id="@+id/clock1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>

In the Analoganddigital.java file, ensure that the main.xml file is loaded as the UI for the activity:

import android.app.Activity; import android.os.Bundle; public class Analoganddigital extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Add the DigitalClock element to main.xml as shown below: <?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" > <AnalogClock android:id="@+id/clock1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <DigitalClock android:id="@+id/clock2" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Output of Analog and Digital Clock:

WebView The WebView view allows you to embed a web browser in your Android applications. Add a new file to the res/layout folder and name it as main.xml and populate it with the following element: <?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" > <WebView android:id="@+id/webview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text = "Hello, world!" /> </LinearLayout>

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Add a new class to the src/net.learn2develop.AndroidViews folder and name it as WebViewExample.java. Populate it as follows: package net.learn2develop.AndroidViews; import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; public class WebViewExample extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.webview); WebView wv = (WebView) findViewById(R.id.webview1); wv.loadUrl("http://www.Google.com"); } }
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

The loadUrl() method of the WebView class loads the page of a given URL. Modify the AndroidManifest.xml file to register the new activity as well as to request for the INTERNET permission: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.learn2develop.AndroidViews" android:versionCode="1" android:versionName="1.0.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".ViewsActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".WebViewExample" android:label="@string/app_name" /> </application> <uses-permission android:name="android.permission.INTERNET">
A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

</uses-permission> <uses-sdk android:minSdkVersion="3" /> </manifest>

For the WebView view to work, you need to add the INTERNET permission to the AndroidManifest.xml file.

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi

Output of WebView:

Summary
The basic unit of the Android UI is the View. A View represents a widget that has an appearance on the screen. Categorized the views in this series into the following group:

Basic Views - commonly-used views such as TextView, EditText, and Button views Picker Views - views that allows users to select from, such as the TimePicker and DatePicker views List Views - views that display a long list of items, such as the ListView and the Spinner views Display Views - views that display images, such as the Gallery and ImageSwitcher views Menus - views that displays additional and context sensitive menu items Additional Views - interesting views such as the AnalogClock and DigitalClock views

A7, Stephanos Tower, Eachamukku, Kakkanadu,Kochi