0% found this document useful (0 votes)
58 views

Android - Lecture 4 (Basic Views)

This document discusses basic views in mobile application development. It defines a view as a basic user interface building block that can display text, buttons, images, and other interactive elements. Common view subclasses include text views, edit texts, buttons, checkboxes and radio buttons. Views have attributes like color, size, and position. The ID attribute uniquely identifies a view. Views are basic elements used to build user interfaces in Android applications.

Uploaded by

namra saboor
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Android - Lecture 4 (Basic Views)

This document discusses basic views in mobile application development. It defines a view as a basic user interface building block that can display text, buttons, images, and other interactive elements. Common view subclasses include text views, edit texts, buttons, checkboxes and radio buttons. Views have attributes like color, size, and position. The ID attribute uniquely identifies a view. Views are basic elements used to build user interfaces in Android applications.

Uploaded by

namra saboor
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

LECTURE – 04

MOBILE APPLICATION
DEVELOPMENT
By: AbuBakar Ubaid
BASIC VIEWS

By: AbuBakar Ubaid


WHAT IS A VIEW?
View subclasses are basic user interface building blocks
● Display text (TextView class), edit text (EditText class)
● Buttons (Button class), menus, other controls
● Scrollable (ScrollView, RecyclerView)
● Show images (ImageView)
● CheckBox
● RadioButton
etc.

By: AbuBakar Ubaid


Examples of VIEW subClass

Button CheckBox

EditText RadioButton

Slider Switch

By: AbuBakar Ubaid


VIEW ATTRIBUTES
● Color, dimensions, positioning
● May have focus (e.g., selected to receive user input)
● May be interactive (respond to user clicks)
● May be visible or not
● Relationships to other views

By: AbuBakar Ubaid


Attributes
• Every View and ViewGroup object supports their own variety of XML
attributes
• Some attributes are specific to a View object , these attributes are
inherited by any View objects that extend this class
• Some attributes are common to all View objects, because they are
inherited from the root View class
• Other attributes are considered "layout parameters "that describe
certain layout orientations of the View object
ID attribute
• Any View object may have an integer ID
• uniquely identify the View within the tree
• the ID is typically assigned in the layout XML file as a string
• This attribute is common to all View objects

android:id"=@+id/my_button"
Using the ID
• The syntax for an ID, inside an XML tag is:
android:id"=@+id/my_button"
• Referencing an Android resource ID:
android:id="@android:id/my_button"
In the layout.xml file:
<Button android:id"=@+id/my_button "
android:layout_width"=wrap_content "
android:layout_height"=wrap_content "
android:text"=@string/my_button_text/">
In the java code:
Button myButton = (Button) findViewById(R.id.my_button);
Text View
• Displays text to the user and optionally allows them to edit it
• TextView is a complete text editor, however the basic class is
configured to not allow editing
Edit Text
• EditText is a thin veneer over TextView that configures itself to be
editable
• Properties:
• capitalize to have the control capitalize words, the beginning of sentences
• phoneNumber property if you need to accept a phone number
• password property if you need a password field
• single line by setting the singleLine property to true
Button
• Button represents a push-button widget
• Push-buttons can be pressed, or clicked, by the user
to perform an action
Button XML declaration
<Button android:id="@+id/ccbtn1"
android:text="@+string/basicBtnLabel"
android:typeface="serif"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
LECTURE – 04 “Basic Views”

THANK YOU 

By: AbuBakar Ubaid

You might also like