You are on page 1of 19

Recap - Layouts

• Components of a screen
1. Linear layout
2. Table layout
3. Relative layout
4. Frame layout
5. Scroll View
Basic Views
Lesson Objectives

By end of this session, students should be able to manipulate;


Basic android views and viewGroups.
• Views
– TextView and EditText
– Button and ImageButton
– CheckBoxes, RadioButtons, and Spinners
• ViewGroups
– GridView
– ListView and ListActivity
– ScrollView
Views

1. TextView and EditText

TextView
• a place to display a text string.
EditText
• includes rich editing capabilities.

• Refer code in file named


“SampleCodes_Views”.
Views

2. Button and ImageButton

• Refer code in file named


“SampleCodes_Views”.
Views

2. Button and ImageButton

• Refer code in file named


“SampleCodes_Views”.
Views

3. CheckBoxes, RadioButtons, and Spinners

• allow user to choose multiple options.


• CheckBoxes - offer multiple selections.
• RadioButtons - only one choice is allowed at a time.
• Spinners
– similar to combo boxes.
– displays currently selected option, with a pull-down list.
• Refer code in file named “SampleCodes_Views”.
Activity

Analyze any one mobile app of your choice.


Views

Checkbox and Radio button


Views

Spinner
ViewGroups

• are Views that contain child Views.


• Descend from the android.view.ViewGroup class.

1. GridView
• descend from the AdapterView class
• displays many child Views that the user can
manipulate.
• two-dimensional array that the user can scroll
vertically.
ViewGroups

1. GridView
• int getCount
Returns the number of items in the data set represented by the Adapter.
• Object getItem(int position)
Returns the object in the Adapter function (Adapter class) at the given position.
• long getItem(int position)
Returns the row ID within the Adapter of the object at the given position.
• View getView(int position, View convertView, ViewGroup parent)
Returns a View object that will display the data in the given position in the data set.
ViewGroups

2. ListView and ListActivity

ListView
• enable to display a long list of items.
• similar to Gallery.
• uses a vertically scrolling list.
• To create a ListView that takes up the entire screen, Android provides the
ListActivity class.
• ListActivity class itself contains a ListView.
ViewGroups

2. ListView
ViewGroups

3. ScrollView

• lets the user scroll the View vertically.


• contains a LinearLayout
• is a FrameLayout, which means that it can have only one child View.
• Refer code in file named “CodeLesson6_widgets”.
ViewGroups

3. ScrollView
Summary

• Views
– TextView and EditText
– Button and ImageButton
– Adapters and AdapterViews
– CheckBoxes, RadioButtons, and
Spinners
• ViewGroups
– GridView
– ListView
– ScrollView
Activity
• Practice all the views and viewgroups using the sample codes uploaded in
Blackboard.

You might also like