The Content helps those who wish to program mobile applications using android platform. The content has been used to conduct mobile application boot camps using android platform on different regions in Tanzania
The document provides steps to create an Android quiz app with a relative layout, background image, image buttons, and text styling. It describes adding a relative layout, adding multiple versions of images for different screens, creating image buttons and positioning them, adding accessibility content descriptions, styling text with a custom font, and making the buttons interactive by adding onclick attributes.
Online tutorial created for android developer - beginners. Step by step instructions with real-time development video. Lesson plan is divided into three part to help create new android project, add new layout, activity and apply styles to widgets.
In this tutorial, we will learn how to open an existing android project and make changes to the existing layout and add new widgets.
For online video presentation, watch our YouTube video:
https://youtu.be/udZVXhf48Gc
This document discusses basic widgets in Android user interfaces. It describes labels, buttons, edit texts, check boxes, spinners, radio groups, radio buttons, images views and image buttons. Labels are used to display text and are not editable. Buttons allow clicking actions. Edit texts are editable like text boxes. Check boxes represent two-state selections. Spinners display a single child like a drop-down list. Radio groups contain radio buttons where only one can be selected at a time. Images can be displayed using image views and buttons. All widgets extend from views and can set properties for visibility, background, focus and enabled status.
Basics and different xml files used in androidMahmudul Hasan
The document discusses XML files used in Android development. It describes 7 types of XML files: 1) layout files define the user interface, 2) manifest files define app components and permissions, 3) strings files replace hardcoded strings, 4) styles files define themes and styles, 5) drawable files provide graphics, 6) color files define color codes, and 7) dimension files define view dimensions. Layout files are located in res/layout and contain views and view groups to build the UI hierarchy.
The document discusses buttons in Android applications. It explains that buttons can contain text or images and are defined in XML layout files using <Button> elements. The document also provides an example XML layout file with an ImageButton and Button, and the corresponding Java code to set onclick listeners for the buttons and display Toast messages when each button is clicked.
The document discusses various types of user interfaces in Android. It describes the view hierarchy in Android using ViewGroups and Views as the basic building blocks. It explains common layouts like LinearLayout, RelativeLayout, TableLayout, GridLayout and ListView that can be used to arrange views. Key classes involved include View, ViewGroup, and different view subclasses that serve as widgets. The document also compares Java and Android approaches to designing user interfaces.
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAhsanul Karim
These slides are for self-learners and trainees of my BASIS and DIIT Android course.
I have used information, content and images from various sources. As these materials are for non-commercial use, I think they won’t infringe any copyright issue.
The Content helps those who wish to program mobile applications using android platform. The content has been used to conduct mobile application boot camps using android platform on different regions in Tanzania
The document provides steps to create an Android quiz app with a relative layout, background image, image buttons, and text styling. It describes adding a relative layout, adding multiple versions of images for different screens, creating image buttons and positioning them, adding accessibility content descriptions, styling text with a custom font, and making the buttons interactive by adding onclick attributes.
Online tutorial created for android developer - beginners. Step by step instructions with real-time development video. Lesson plan is divided into three part to help create new android project, add new layout, activity and apply styles to widgets.
In this tutorial, we will learn how to open an existing android project and make changes to the existing layout and add new widgets.
For online video presentation, watch our YouTube video:
https://youtu.be/udZVXhf48Gc
This document discusses basic widgets in Android user interfaces. It describes labels, buttons, edit texts, check boxes, spinners, radio groups, radio buttons, images views and image buttons. Labels are used to display text and are not editable. Buttons allow clicking actions. Edit texts are editable like text boxes. Check boxes represent two-state selections. Spinners display a single child like a drop-down list. Radio groups contain radio buttons where only one can be selected at a time. Images can be displayed using image views and buttons. All widgets extend from views and can set properties for visibility, background, focus and enabled status.
Basics and different xml files used in androidMahmudul Hasan
The document discusses XML files used in Android development. It describes 7 types of XML files: 1) layout files define the user interface, 2) manifest files define app components and permissions, 3) strings files replace hardcoded strings, 4) styles files define themes and styles, 5) drawable files provide graphics, 6) color files define color codes, and 7) dimension files define view dimensions. Layout files are located in res/layout and contain views and view groups to build the UI hierarchy.
The document discusses buttons in Android applications. It explains that buttons can contain text or images and are defined in XML layout files using <Button> elements. The document also provides an example XML layout file with an ImageButton and Button, and the corresponding Java code to set onclick listeners for the buttons and display Toast messages when each button is clicked.
The document discusses various types of user interfaces in Android. It describes the view hierarchy in Android using ViewGroups and Views as the basic building blocks. It explains common layouts like LinearLayout, RelativeLayout, TableLayout, GridLayout and ListView that can be used to arrange views. Key classes involved include View, ViewGroup, and different view subclasses that serve as widgets. The document also compares Java and Android approaches to designing user interfaces.
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAhsanul Karim
These slides are for self-learners and trainees of my BASIS and DIIT Android course.
I have used information, content and images from various sources. As these materials are for non-commercial use, I think they won’t infringe any copyright issue.
This document provides information about a mobile application development course including:
- The course teacher and outcomes which include explaining Android features, configuring development tools, designing user interfaces using layouts and components.
- Commonly used Android view classes for creating user interfaces like TextView, EditText, Button, ImageView, CheckBox, RadioButton, ListView and more.
- Code examples for implementing views like ImageView, CheckBox, RadioButton, RadioGroup, ImageButton, ProgressBar and more.
This document provides an overview and tutorial on developing Android applications. It discusses the Android architecture and tools used for development, including Eclipse IDE, Android SDK, and Android Virtual Device (AVD). It demonstrates how to create a "Hello World" Android app by setting up an AVD, creating a new project in Eclipse, configuring the project to run on the AVD, and testing the application output. The document also covers Android application components like layouts, views, resources and the manifest file. It provides examples of creating user interface elements programmatically and handling common view events.
The document discusses various Android widgets such as TextView, ImageView, EditText, CheckBox, and RadioButton. It provides code examples for how to implement each widget in an Android application. For TextView, it demonstrates how to display simple text. For ImageView, it shows how to display an image. For EditText, it explains how to create an editable text field. For CheckBox, it provides an example of a checkbox that can be checked or unchecked. And for RadioButton, it discusses using radio buttons within a RadioGroup so that only one can be selected at a time.
1) The document describes building a simple user interface with an XML layout containing an EditText field and a Button. It explains how to define the UI elements in XML and add string resources for the text labels.
2) Key steps include creating a LinearLayout, adding an EditText and Button, setting attributes like IDs and dimensions, and externalizing strings to a resources file for localization.
3) Running the app displays the basic UI layout with an input field and button as defined in the XML code.
The document provides information about creating user interface elements like TextView, Button, and Spinner dynamically in Kotlin code. It explains how to define the elements in XML layout files and access them in Kotlin activities to set onClickListeners and other functionality. Key steps include modifying layout XML files, strings resources, and accessing elements and adding functionality in Kotlin files.
In this chapter we will see the various element of Android SDK, we will see more about their usage in User Interface Design. One of the most basic user interface elements, or controls, in the Android SDK is the TextView control. You use it, quite simply, to draw text on the screen. You primarily use it to display fixed text strings or labels.
This document provides information on various widgets and UI elements in Android, including TextViews, EditTexts, buttons, checkboxes, radio buttons, toggle buttons, spinners, list views, alert dialogs, pickers, the ActionBar, and notifications. It describes the XML attributes and common methods for each widget, and provides references to the Android developer documentation for further information. It also includes examples of how to implement things like custom dialogs, navigation with the up button, adding an action view to the ActionBar, and displaying notifications.
Android User Interface: Basic Form WidgetsAhsanul Karim
This document provides a tutorial on creating various user interface elements in Android applications, including buttons, text fields, checkboxes, radio buttons, toggle buttons, rating bars, and auto-complete text views. It includes code examples for adding each element to an app layout and handling user interactions with them.
This document provides an overview of events, the code window, and adding code in Visual Basic 2005. It describes how Windows is event-driven and events must be handled by writing event procedures. The code window is accessed by double-clicking an object like a command button. Code is added like in a word processor. PictureBox controls can display images on a form, and properties like SizeMode and Visible control appearance. Setting properties in code allows changing them dynamically. The AcceptButton and CancelButton properties determine which buttons respond to Enter and Esc.
The document provides instructions on installing the Android SDK and setting up a development environment in Netbeans or Eclipse. It describes the basic building blocks of an Android application including activities, intents, services, and content providers. It also covers creating user interfaces with views and view hierarchies, handling click events, and building a simple form layout with widgets like text fields, buttons, and radio buttons.
Android Application Development - Level 1Isham Rashik
Very basics of Android Application Development for the beginners who have no prior experience with programming. Can be used for hobby purpose as well as educational material for the academic purpose.
Android Development for Beginners with Sample Project - Day 1Joemarie Amparo
Android Development Training for Beginners covers an overview of Android, installing the Android Development Tools (ADT) plugin for Eclipse, exploring project components, creating a sample Android project, and running the project. The document outlines the first day module which introduces Android, explains that it is an open source mobile platform developed by Google and the Open Handset Alliance, and defines the software stack. It also provides a brief history of Android and versions released. The document discusses project structure, layouts, strings, the manifest file, and includes code examples for creating an activity and handling button clicks.
The document discusses different types of views and view groups in Android user interface development. It describes layouts like LinearLayout, RelativeLayout and FrameLayout that extend the ViewGroup class. These layouts allow arranging views in different orientations using attributes like layout_width, layout_height, layout_weight etc. The document also talks about defining views and layouts in XML files or programmatically at runtime.
While it is technically possible to create and attach widgets to your activity purely through Java code, the more common approach is to use an XML-based layout file. Dynamic instantiation of widgets is reserved for more complicated scenarios, where the widgets are not known at compile time (e.g., populating a column of radio buttons based on data retrieved from the Internet).
With that in mind, this chapter discuss the XML way to lay out Android activity views that way
Android Development Made Easy - With Sample ProjectJoemarie Amparo
Android is an open source operating system developed by Google and the Open Handset Alliance. This document provides an overview of Android and how to create a sample Android project in Eclipse. It discusses Android versions, the project components like activities and services, and how to add a layout, strings, and additional activities. Creating the sample project involves adding buttons, text views and intents to launch a new activity when a button is clicked.
This document provides information about a mobile application development course including:
- The course teacher and outcomes which include explaining Android features, configuring development tools, designing user interfaces using layouts and components.
- Commonly used Android view classes for creating user interfaces like TextView, EditText, Button, ImageView, CheckBox, RadioButton, ListView and more.
- Code examples for implementing views like ImageView, CheckBox, RadioButton, RadioGroup, ImageButton, ProgressBar and more.
This document provides an overview and tutorial on developing Android applications. It discusses the Android architecture and tools used for development, including Eclipse IDE, Android SDK, and Android Virtual Device (AVD). It demonstrates how to create a "Hello World" Android app by setting up an AVD, creating a new project in Eclipse, configuring the project to run on the AVD, and testing the application output. The document also covers Android application components like layouts, views, resources and the manifest file. It provides examples of creating user interface elements programmatically and handling common view events.
The document discusses various Android widgets such as TextView, ImageView, EditText, CheckBox, and RadioButton. It provides code examples for how to implement each widget in an Android application. For TextView, it demonstrates how to display simple text. For ImageView, it shows how to display an image. For EditText, it explains how to create an editable text field. For CheckBox, it provides an example of a checkbox that can be checked or unchecked. And for RadioButton, it discusses using radio buttons within a RadioGroup so that only one can be selected at a time.
1) The document describes building a simple user interface with an XML layout containing an EditText field and a Button. It explains how to define the UI elements in XML and add string resources for the text labels.
2) Key steps include creating a LinearLayout, adding an EditText and Button, setting attributes like IDs and dimensions, and externalizing strings to a resources file for localization.
3) Running the app displays the basic UI layout with an input field and button as defined in the XML code.
The document provides information about creating user interface elements like TextView, Button, and Spinner dynamically in Kotlin code. It explains how to define the elements in XML layout files and access them in Kotlin activities to set onClickListeners and other functionality. Key steps include modifying layout XML files, strings resources, and accessing elements and adding functionality in Kotlin files.
In this chapter we will see the various element of Android SDK, we will see more about their usage in User Interface Design. One of the most basic user interface elements, or controls, in the Android SDK is the TextView control. You use it, quite simply, to draw text on the screen. You primarily use it to display fixed text strings or labels.
This document provides information on various widgets and UI elements in Android, including TextViews, EditTexts, buttons, checkboxes, radio buttons, toggle buttons, spinners, list views, alert dialogs, pickers, the ActionBar, and notifications. It describes the XML attributes and common methods for each widget, and provides references to the Android developer documentation for further information. It also includes examples of how to implement things like custom dialogs, navigation with the up button, adding an action view to the ActionBar, and displaying notifications.
Android User Interface: Basic Form WidgetsAhsanul Karim
This document provides a tutorial on creating various user interface elements in Android applications, including buttons, text fields, checkboxes, radio buttons, toggle buttons, rating bars, and auto-complete text views. It includes code examples for adding each element to an app layout and handling user interactions with them.
This document provides an overview of events, the code window, and adding code in Visual Basic 2005. It describes how Windows is event-driven and events must be handled by writing event procedures. The code window is accessed by double-clicking an object like a command button. Code is added like in a word processor. PictureBox controls can display images on a form, and properties like SizeMode and Visible control appearance. Setting properties in code allows changing them dynamically. The AcceptButton and CancelButton properties determine which buttons respond to Enter and Esc.
The document provides instructions on installing the Android SDK and setting up a development environment in Netbeans or Eclipse. It describes the basic building blocks of an Android application including activities, intents, services, and content providers. It also covers creating user interfaces with views and view hierarchies, handling click events, and building a simple form layout with widgets like text fields, buttons, and radio buttons.
Android Application Development - Level 1Isham Rashik
Very basics of Android Application Development for the beginners who have no prior experience with programming. Can be used for hobby purpose as well as educational material for the academic purpose.
Android Development for Beginners with Sample Project - Day 1Joemarie Amparo
Android Development Training for Beginners covers an overview of Android, installing the Android Development Tools (ADT) plugin for Eclipse, exploring project components, creating a sample Android project, and running the project. The document outlines the first day module which introduces Android, explains that it is an open source mobile platform developed by Google and the Open Handset Alliance, and defines the software stack. It also provides a brief history of Android and versions released. The document discusses project structure, layouts, strings, the manifest file, and includes code examples for creating an activity and handling button clicks.
The document discusses different types of views and view groups in Android user interface development. It describes layouts like LinearLayout, RelativeLayout and FrameLayout that extend the ViewGroup class. These layouts allow arranging views in different orientations using attributes like layout_width, layout_height, layout_weight etc. The document also talks about defining views and layouts in XML files or programmatically at runtime.
While it is technically possible to create and attach widgets to your activity purely through Java code, the more common approach is to use an XML-based layout file. Dynamic instantiation of widgets is reserved for more complicated scenarios, where the widgets are not known at compile time (e.g., populating a column of radio buttons based on data retrieved from the Internet).
With that in mind, this chapter discuss the XML way to lay out Android activity views that way
Android Development Made Easy - With Sample ProjectJoemarie Amparo
Android is an open source operating system developed by Google and the Open Handset Alliance. This document provides an overview of Android and how to create a sample Android project in Eclipse. It discusses Android versions, the project components like activities and services, and how to add a layout, strings, and additional activities. Creating the sample project involves adding buttons, text views and intents to launch a new activity when a button is clicked.
Similar to Mobile Application Development-Designing User Interface With View (20)
Applications of artificial Intelligence in Mechanical Engineering.pdfAtif Razi
Historically, mechanical engineering has relied heavily on human expertise and empirical methods to solve complex problems. With the introduction of computer-aided design (CAD) and finite element analysis (FEA), the field took its first steps towards digitization. These tools allowed engineers to simulate and analyze mechanical systems with greater accuracy and efficiency. However, the sheer volume of data generated by modern engineering systems and the increasing complexity of these systems have necessitated more advanced analytical tools, paving the way for AI.
AI offers the capability to process vast amounts of data, identify patterns, and make predictions with a level of speed and accuracy unattainable by traditional methods. This has profound implications for mechanical engineering, enabling more efficient design processes, predictive maintenance strategies, and optimized manufacturing operations. AI-driven tools can learn from historical data, adapt to new information, and continuously improve their performance, making them invaluable in tackling the multifaceted challenges of modern mechanical engineering.
Home security is of paramount importance in today's world, where we rely more on technology, home
security is crucial. Using technology to make homes safer and easier to control from anywhere is
important. Home security is important for the occupant’s safety. In this paper, we came up with a low cost,
AI based model home security system. The system has a user-friendly interface, allowing users to start
model training and face detection with simple keyboard commands. Our goal is to introduce an innovative
home security system using facial recognition technology. Unlike traditional systems, this system trains
and saves images of friends and family members. The system scans this folder to recognize familiar faces
and provides real-time monitoring. If an unfamiliar face is detected, it promptly sends an email alert,
ensuring a proactive response to potential security threats.
Discover the latest insights on Data Driven Maintenance with our comprehensive webinar presentation. Learn about traditional maintenance challenges, the right approach to utilizing data, and the benefits of adopting a Data Driven Maintenance strategy. Explore real-world examples, industry best practices, and innovative solutions like FMECA and the D3M model. This presentation, led by expert Jules Oudmans, is essential for asset owners looking to optimize their maintenance processes and leverage digital technologies for improved efficiency and performance. Download now to stay ahead in the evolving maintenance landscape.
Software Engineering and Project Management - Introduction, Modeling Concepts...Prakhyath Rai
Introduction, Modeling Concepts and Class Modeling: What is Object orientation? What is OO development? OO Themes; Evidence for usefulness of OO development; OO modeling history. Modeling
as Design technique: Modeling, abstraction, The Three models. Class Modeling: Object and Class Concept, Link and associations concepts, Generalization and Inheritance, A sample class model, Navigation of class models, and UML diagrams
Building the Analysis Models: Requirement Analysis, Analysis Model Approaches, Data modeling Concepts, Object Oriented Analysis, Scenario-Based Modeling, Flow-Oriented Modeling, class Based Modeling, Creating a Behavioral Model.
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELijaia
As digital technology becomes more deeply embedded in power systems, protecting the communication
networks of Smart Grids (SG) has emerged as a critical concern. Distributed Network Protocol 3 (DNP3)
represents a multi-tiered application layer protocol extensively utilized in Supervisory Control and Data
Acquisition (SCADA)-based smart grids to facilitate real-time data gathering and control functionalities.
Robust Intrusion Detection Systems (IDS) are necessary for early threat detection and mitigation because
of the interconnection of these networks, which makes them vulnerable to a variety of cyberattacks. To
solve this issue, this paper develops a hybrid Deep Learning (DL) model specifically designed for intrusion
detection in smart grids. The proposed approach is a combination of the Convolutional Neural Network
(CNN) and the Long-Short-Term Memory algorithms (LSTM). We employed a recent intrusion detection
dataset (DNP3), which focuses on unauthorized commands and Denial of Service (DoS) cyberattacks, to
train and test our model. The results of our experiments show that our CNN-LSTM method is much better
at finding smart grid intrusions than other deep learning algorithms used for classification. In addition,
our proposed approach improves accuracy, precision, recall, and F1 score, achieving a high detection
accuracy rate of 99.50%.
Mechatronics is a multidisciplinary field that refers to the skill sets needed in the contemporary, advanced automated manufacturing industry. At the intersection of mechanics, electronics, and computing, mechatronics specialists create simpler, smarter systems. Mechatronics is an essential foundation for the expected growth in automation and manufacturing.
Mechatronics deals with robotics, control systems, and electro-mechanical systems.
Blood finder application project report (1).pdfKamal Acharya
Blood Finder is an emergency time app where a user can search for the blood banks as
well as the registered blood donors around Mumbai. This application also provide an
opportunity for the user of this application to become a registered donor for this user have
to enroll for the donor request from the application itself. If the admin wish to make user
a registered donor, with some of the formalities with the organization it can be done.
Specialization of this application is that the user will not have to register on sign-in for
searching the blood banks and blood donors it can be just done by installing the
application to the mobile.
The purpose of making this application is to save the user’s time for searching blood of
needed blood group during the time of the emergency.
This is an android application developed in Java and XML with the connectivity of
SQLite database. This application will provide most of basic functionality required for an
emergency time application. All the details of Blood banks and Blood donors are stored
in the database i.e. SQLite.
This application allowed the user to get all the information regarding blood banks and
blood donors such as Name, Number, Address, Blood Group, rather than searching it on
the different websites and wasting the precious time. This application is effective and
user friendly.
Accident detection system project report.pdfKamal Acharya
The Rapid growth of technology and infrastructure has made our lives easier. The
advent of technology has also increased the traffic hazards and the road accidents take place
frequently which causes huge loss of life and property because of the poor emergency facilities.
Many lives could have been saved if emergency service could get accident information and
reach in time. Our project will provide an optimum solution to this draw back. A piezo electric
sensor can be used as a crash or rollover detector of the vehicle during and after a crash. With
signals from a piezo electric sensor, a severe accident can be recognized. According to this
project when a vehicle meets with an accident immediately piezo electric sensor will detect the
signal or if a car rolls over. Then with the help of GSM module and GPS module, the location
will be sent to the emergency contact. Then after conforming the location necessary action will
be taken. If the person meets with a small accident or if there is no serious threat to anyone’s
life, then the alert message can be terminated by the driver by a switch provided in order to
avoid wasting the valuable time of the medical rescue team.
Supermarket Management System Project Report.pdfKamal Acharya
Supermarket management is a stand-alone J2EE using Eclipse Juno program.
This project contains all the necessary required information about maintaining
the supermarket billing system.
The core idea of this project to minimize the paper work and centralize the
data. Here all the communication is taken in secure manner. That is, in this
application the information will be stored in client itself. For further security the
data base is stored in the back-end oracle and so no intruders can access it.
2. TextView
Basically in Android Studio the Android TextView; UI component is used to display text to the user.
TextView is optionally is editable.
Attributes Descriptions
android : id To identifies the control uniquely we use ID attribute.
android : width
To specify the size (width) of controls. Possible values are pt, px, dp etc.(i.e 10pt, 155px,
230dp etc).
android : height
To specify the size(width) of controls. Possible values are pt, px, dp etc.(i.e 10pt, 155px,
230dp etc).
android : fontSize
It is used to specify the text size. Possible values are pt, px, dp etc.(i.e 10pt, 155px,
230dp etc).
android : gravity
It is used for text alignment inside textView. Possible values are center, left, right,
center_vertically, center_horizontally etc.
android : layoutGravity
It is used for textView layout alignment in parent layout. Possible values are center, left,
right, center_vertically, center_horizontally etc.
android : text Text to display on textView.
android : textColor
To specify the color of text in TextView. Possible values are HEX (#rrggbb) code. (i.e)
#CECECE
android : hint The text to display when TextView is empty.
android : capitalize
If set, specifies that this TextView has a textual input method and should automatically
capitalize what the user types.
3. TextView
Attributes Descriptions
android : cursorVisible To specify the visibility of cursor in TextView. Possbile values are Boolean “true” or “false”.
android : fontFamily To specify the text (font family) in TextView.
android : textAllCaps To capitalize all text of TextView. Possible values are Boolean “true” or “false”.
android :
textColorHighlight
Color of the text selection highlight.
android : textColorHint To specify the color of hint text.
android :
textIsSelectable
Indicates that the content of a non-editable text can be selected. Possible value either
“true” or “false”.
android : textStyle To gives style to the text in TextView. Possible values are bold, normal, italic.
android : inputType
The type of data being placed in a text field. Phone, Date, Time, Number, Password etc
android : maxWidth Makes the TextView be at most this many pixels wide.
android : maxHeight Makes the TextView be at most this many pixels tall.
android : minWidth Makes the TextView be at least this many pixels wide.
android : minHeight Makes the TextView be at least this many pixels tall.
Assignment 7_1
4. EditText
In Android, EditText is a standard entry widget in android apps. It is an overlay over TextView that configures itself to be
editable. EditText is a subclass of TextView with text editing operations. We often use EditText in our applications in order
to provide an input or text field, especially in forms.
Attribute Description
android:id It is used to uniquely identify the control
android:gravity It is used to specify how to align the text like left, right, center, top, etc.
android:text It is used to set the text.
android:hint It is used to display the hint text when text is empty
android:textColor It is used to change the color of the text.
android:textColorHint It is used to change the text color of hint text.
android:textSize It is used to specify the size of the text.
android:textStyle It is used to change the style (bold, italic, bolditalic) of text.
android:background It is used to set the background color for edit text control
android:width It makes the TextView be exactly this many pixels wide.
android:height It makes the TextView be exactly this many pixels tall.
android:maxWidth It is used to make the TextView be at most this many pixels wide.
android:minWidth It is used to make the TextView be at least this many pixels wide.
android:textAllCaps It is used to present the text in all CAPS
android:inputType It is used to specify the type of text being placed in text fields.
android:fontFamily It is used to specify the fontFamily for the text.
android:editable If we set false, EditText won't allow us to enter or modify the text
5. Button
In android, Button is a user interface control that is used to perform an action whenever the user clicks or tap on
it. Generally, Buttons in android will contain a text or an icon or both and perform an action when the user
touches it. Following is the pictorial representation of using Buttons in android applications.
In android, we have a different type of buttons available to use based on our requirements, those are ImageButton,
ToggleButton, RadioButton.
In android, we can create a Button control in two ways either in the XML layout file or create it in the Activity file
programmatically.
Create Button in XML Layout File
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/addBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add" />
</LinearLayout>
6. Button
Create Button Control in Activity File
In android, we can create Button control programmatically in an activity file based on our requirements.
Following is the example of creating Button control dynamically in the activity file.
LinearLayout layout = (LinearLayout)findViewById(R.id.l_layout);
Button btn = new Button(this);
btn.setText("Test");
layout.addView(btn);
Define Button Click Event in XML Layout File
We can define click event handler for button by adding android:onClick attribute to the <Button> element
in our XML layout file.
The value of android:onClick attribute must be the name of the method which we need to call in response to
a click event and the Activity file which hosting XML layout must implement the corresponding method.
Following is the example of defining a button click event using android:onClick attribute in an XML layout
file.
7. Button
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/addBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"
android:onClick="addOperation"/>
</LinearLayout>
In Activity that hosts our XML layout file, we need to implement click event method like as shown below
/** Called when the user touches the button */
public void addOperation(View view) {
// Do something in response to the button click
}
8. Button
Define Button Click Event in Activity File
• In android, we can define the button click event programmatically in the Activity file rather than XML
layout file.
• To define button click programmatically, create View.OnClickListener object and assign it to the button
by calling setOnClickListener(View.OnClickListener) like as shown below.
Button btnAdd = (Button)findViewById(R.id.addBtn);
btnAdd.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Do something in response to button click
}
});
}
9. Button
Attribute Description
android:id It is used to uniquely identify the control
android:gravity It is used to specify how to align the text like left, right, center, top, etc.
android:text It is used to set the text.
android:textColor It is used to change the color of text.
android:textSize It is used to specify the size of the text.
android:textStyle It is used to change the style (bold, italic, bolditalic) of text.
android:background It is used to set the background color for button control.
android:padding It is used to set the padding from left, right, top and bottom.
android:drawableBottom It’s drawable to be drawn to the below of text.
android:drawableRight It’s drawable to be drawn to the right of text.
android:drawableLeft It’s drawable to be drawn to the left of the text.
10. ImageButton
In android, Image Button is a user interface control that is used to display a button with an image and to
perform an action when a user clicks or taps on it.
By default, the ImageButton looks same as normal button and it performs an action when a user clicks or
touches it, but the only difference is we will add a custom image to the button instead of text.
Following is the pictorial representation of using Image Buttons in android applications.
In android, we can add an image to the button by using <ImageButton> attribute android:src in XML layout file
or by using the setImageResource() method.
In android, we can create ImageButton control in two ways either in the XML layout file or create it in the Activity
file programmatically.
11. ImageButton
Create ImageButton in XML Layout File
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/addBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/add_icon" />
</LinearLayout>
Create ImageButton Control in Activity File
LinearLayout layout = (LinearLayout)findViewById(R.id.l_layout);
ImageButton btn = new ImageButton(this);
btn.setImageResource(R.drawable.add_icon);
layout.addView(btn);
12. ImageButton
Anndroid Handle ImageButton Click Events
Generally, whenever the user clicks on ImageButton, the ImageButton object will receives an on-click event.
In android, we can define button click event in two ways either in XML layout file or create it in Activity file
programmatically.
i. Define ImageButton Click Event in XML Layout File
We can define click event handler for button by adding android:onClick attribute to
the <ImageButton> element in our XML layout file.
The value of android:onClick attribute must be the name of method which we need to call in response to a
click event and the Activity file which hosting XML layout must implement the corresponding method.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/addBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/add_icon" android:onClick="addOperation"/>
</LinearLayout>
13. ImageButton Anndroid Handle ImageButton Click Events
• Generally, whenever the user clicks on ImageButton, the ImageButton object will receives an on-click event.
• In android, we can define button click event in two ways either in XML layout file or create it in Activity file programmatically.
i. Define ImageButton Click Event in XML Layout File
• We can define click event handler for button by adding android:onClick attribute to the <ImageButton> element in
our XML layout file.
• The value of android:onClick attribute must be the name of method which we need to call in response to a click event
and the Activity file which hosting XML layout must implement the corresponding method.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/addBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/add_icon" android:onClick="addOperation"/>
</LinearLayout>
In Activity that hosts our XML layout file, we need to implement click event method like as shown below
/** Called when the user touches the button */
public void addOperation(View view) {
// Do something in response to button click
14. ImageButton Anndroid Handle ImageButton Click Events
ii. Define ImageButton Click Event in Activity File
• In android, we can define ImageButton click event programmatically in Activity file rather than XML layout
file.
• To define button click programmatically, create View.OnClickListener object and assign it to the button by
calling setOnClickListener(View.OnClickListener) like as shown below.
ImageButton btnAdd = (ImageButton)findViewById(R.id.addBtn);
btnAdd.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Do something in response to button click
}
});
}
15. Android ImageButton Control Attributes
Attribute Description
android:id It is used to uniquely identify the control
android:src It is used to specify the source file of an image
android:background It is used to set the background color for an image button control.
android:padding It is used to set the padding from left, right, top and bottom of the image button.
android:baseline It is used to set the offset of the baseline within the view.
16. ToggleButton
In android, Toggle Button is a user interface control that is used to display ON (Checked) or OFF (Unchecked)
states as a button with a light indicator.
The ToggleButton is useful for the users to change the settings between two states either ON or OFF. We can
add a ToggleButton to our application layout by using the ToggleButton object.
Following is the pictorial representation of using ToggleButton in android applications.
By default, the android ToggleButton will be in OFF (Unchecked) state. We can change the default state of
ToggleButton by using android:checked attribute.
In case, if we want to change the state of ToggleButton to ON (Checked), then we need to set android:checked
= “true” in our XML layout file.
In android, we can create ToggleButton control in two ways either in the XML layout file or create it in the
Activity file programmatically.
17. ToggleButton
Create ToggleButton in XML Layout File
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<ToggleButton
android:id="@+id/toggle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="120dp"
android:checked="true"
android:textOff="OFF"
android:textOn="ON"/>
</RelativeLayout>
Create ToggleButton Control in Activity File
RelativeLayout layout = (RelativeLayout)findViewById(R.id.r_layout);
ToggleButton tb = new ToggleButton(this);
tb.setTextOff("OFF");
tb.setTextOn("ON");
tb.setChecked(true);
layout.addView(tb);
18. ToggleButton
Handle Android ToggleButton Click Events
Generally, whenever the user clicks on ToggleButton, we can detect whether ToggleButton is in ON or OFF
state and we can handle the ToggleButton click event in activity file using setOnCheckedChangeListener
like as shown below.
ToggleButton toggle = (ToggleButton) findViewById(R.id.togglebutton);
toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
// The toggle is enabled
} else {
// The toggle is disabled
}
}
});
19. ToggleButton
Attribute Description
android:id It is used to uniquely identify the control
android:checked It is used to specify the current state of toggle button
android:gravity It is used to specify how to align the text like left, right, center, top,
etc.
android:text It is used to set the text.
android:textOn It is used to set the text when the toggle button is in the ON / Checked
state.
android:textOff It is used to set the text when the toggle button is in the OFF /
Unchecked state.
android:textColor It is used to change the color of text.
android:textSize It is used to specify the size of text.
android:textStyle It is used to change the style (bold, italic, bolditalic) of text.
android:background It is used to set the background color for toggle button control.
android:padding It is used to set the padding from left, right, top and bottom.
android:drawableBottom It’s drawable to be drawn to the below text.
android:drawableRight It’s drawable to be drawn to the right of the text.
android:drawableLeft It’s drawable to be drawn to the left of text.
20. AutoCompleteTextView
In android, AutoCompleteTextView is an editable text view which is used to show the list of suggestions based
on the user typing text. The list of suggestions will be shown as a dropdown menu from which the user can
choose an item to replace the content of the textbox.
The AutoCompleteTextView is a subclass of EditText class so we can inherit all the properties of EditText in
AutoCompleteTextView based on our requirements.
Following is the pictorial representation of using AutoCompleteTextView in android applications.
21. AutoCompleteTextView
In android, we can create an AutoCompleteTextView control in two ways either in the XML layout file or create
it in the Activity file programmatically.
Create AutoCompleteTextView Control in Activity File
Create AutoCompleteTextView in Layout File
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<AutoCompleteTextView
android:id="@+id/autoComplete_Country"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
LinearLayout l_layout = (LinearLayout) findViewById(R.id.linear_Layout);
AutoCompleteTextView actv = new AutoCompleteTextView(this);
l_layout.addView(actv);
22. AutoCompleteTextView
Set the Text of Android AutoCompleteTextView
Create AutoCompleteTextView in Layout File
String[] Countries = { "India", "USA", "Australia", "UK", "Italy", "Ireland", "Africa" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, Countries);
AutoCompleteTextView actv = AutoCompleteTextView)findViewById(R.id.autoComplete_Country);
actv.setAdapter(adapter);
In android, we can set the text of AutoCompleteTextView control by using setAdapter() method in Activity file.
Following is example of binding data AutoCompleteTextView in activity file using setAdapter() method.
Study the example for Experiment 8
23. AutoCompleteTextView
Android AutoCompleteTextView Attributes
Attribute Description
android:id It is used to uniquely identify the control
android:gravity It is used to specify how to align the text like left, right, center, top, etc.
android:text It is used to set the text.
android:hint It is used to display the hint text when text is empty
android:textColor It is used to change the color of the text.
android:textColorHint It is used to change the text color of hint text.
android:textSize It is used to specify the size of text.
android:textStyle It is used to change the style (bold, italic, bolditalic) of text.
android:background It is used to set the background color for autocomplete textview control
android:ems It is used to make the textview be exactly this many ems wide.
android:width It makes the TextView be exactly this many pixels wide.
android:height It makes the TextView be exactly this many pixels tall.
android:textColorHighlight It is used to change the color of the text selection highlight.
android:fontFamily It is used to specify the fontFamily for the text.
24. CheckBox
In android, CheckBox is a two-states button that can be either checked (ON) or unchecked (OFF) and it will
allow users to toggle between the two states (ON / OFF) based on the requirements.
Generally, we can use multiple CheckBox controls in android application to allow users to select one or more
options from the set of values.
Following is the pictorial representation of using CheckBox control in android applications.
By default, the android ToggleButton will be in OFF (Unchecked) state. We can change the default state of
ToggleButton by using android:checked attribute.
In case, if we want to change the state of ToggleButton to ON (Checked), then we need to set android:checked
= “true” in our XML layout file.
In android, we can create ToggleButton control in two ways either in the XML layout file or create it in the
Activity file programmatically.
25. CheckBox
Create CheckBox in XML Layout File
If you observe above code snippet, here we defined CheckBox control and setting CheckBox
state ON using android:checked attribute in xml layout file.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<CheckBox
android:id="@+id/chk1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Java" /> </RelativeLayout>
Create CheckBox Control in Activity File
Following is the example of creating a CheckBox control dynamically in an activity file.
LinearLayout layout = (LinearLayout)findViewById(R.id.l_layout);
CheckBox cb = new CheckBox(this);
cb.setText("Tutlane");
cb.setChecked(true);
layout.addView(cb);
26. CheckBox
Handle Android CheckBox Click Events
Generally, whenever the user clicks on CheckBox to Select or Deselect the CheckBox object will receive an on-
click event.
In android, we can define the CheckBox click event in two ways either in the XML layout file or create it in
the Activity file programmatically.
Define CheckBox Click Event in XML Layout File
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<CheckBox
android:id="@+id/chk1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Java" android:onClick="onCheckBoxClick"/>
</LinearLayout>
27. CheckBox
Handle Android CheckBox Click Events
public void onCheckboxClicked(View view) {
// Is the view now checked?
boolean checked = ((CheckBox) view).isChecked();
// Check which checkbox was clicked
switch(view.getId()) {
case R.id.chk1:
if (checked)
// Do your coding
else
// Do your coding
break;
// Perform your logic
}
}
28. CheckBox
Handle Android CheckBox Click Events
In android, we can define CheckBox click event programmatically in Activity file rather than XML layout file.
To define checkbox click event programmatically, create View.OnClickListener object and assign it to the button by
calling setOnClickListener(View.OnClickListener) like as shown below.
CheckBox chk = (CheckBox) findViewById(R.id.chk1);
chk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = ((CheckBox) v).isChecked();
// Check which checkbox was clicked
if (checked){
// Do your coding
}
else{
// Do your coding
}
}
});
29. CheckBox
Handle Android CheckBox Click Events
In android, we can define CheckBox click event programmatically in Activity file rather than XML layout file.
To define checkbox click event programmatically, create View.OnClickListener object and assign it to the button by
calling setOnClickListener(View.OnClickListener) like as shown below.
CheckBox chk = (CheckBox) findViewById(R.id.chk1);
chk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = ((CheckBox) v).isChecked();
// Check which checkbox was clicked
if (checked){
// Do your coding
}
else{
// Do your coding
}
}
});
30. CheckBox
Android CheckBox Control Attributes
Attribute Description
android:id It is used to uniquely identify the control
android:checked It is used to specify the current state of checkbox
android:gravity It is used to specify how to align the text like left, right, center, top, etc.
android:text It is used to set the text for a checkbox.
android:textColor It is used to change the color of text.
android:textSize It is used to specify the size of text.
android:textStyle It is used to change the style (bold, italic, bolditalic) of text.
android:background It is used to set the background color for checkbox control.
android:padding It is used to set the padding from left, right, top and bottom.
android:onClick It’s the name of the method to invoke when the checkbox clicked.
android:visibility It is used to control the visibility of control.
31. RadioButton and RadioGroup
In android, Radio Button is a two-states button that can be either checked or unchecked and it’s the same
as CheckBox control, except that it will allow only one option to select from the group of options.
The user can press or click on the radio button to make it select. In android, CheckBox control allow users to change the
state of control either Checked or Unchecked but the radio button cannot be unchecked once it is checked.
Generally, we can use RadioButton controls in an android application to allow users to select only one option from the set
of values.
Following is the pictorial representation of using RadioButton control in android applications..
32. RadioButton and RadioGroup
In android, we use radio buttons with in a RadioGroup to combine multiple radio buttons into one group and
it will make sure that users can select only one option from the group of multiple options.
By default, the android RadioButton will be in OFF (Unchecked) state. We can change the default state
of RadioButton by using android:checked attribute.
In case, if we want to change the state of RadioButton to ON (Checked), then we need to
set android:checked = “true” in our XML layout file.
In android, we can create RadioButton control in two ways either in the XML layout file or create it in
the Activity file programmatically.
33. RadioButton and RadioGroup
Create RadioButton in XML Layout File
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Java"
android:checked="true"/>
</RelativeLayout>
34. RadioButton and RadioGroup
Create RadioButton Control in Activity File
In android, we can create RadioButton control programmatically in activity file based on our requirements.
Following is the example of creating a RadioButton control dynamically in activity file.
LinearLayout layout = (LinearLayout)findViewById(R.id.l_layout);
RadioButton rd = new RadioButton(this);
rd.setText("Tutlane");
rd.setChecked(true);
layout.addView(rd);
Define RadioButton Click Event in XML Layout File
We can define click event handler for button by adding the android:onClick attribute to
the <RadioButton> element in our XML layout file.
The value of android:onClick attribute must be the name of the method which we need to call in response
to a click event and the Activity file which hosting XML layout must implement the corresponding method.
Following is the example of defining a RadioButton click event using android:onClick attribute in XML
layout file.
36. RadioButton and RadioGroup
In Activity that hosts our XML layout file, we need to implement click event method like as shown below.
public void onRadioButtonClicked(View view) {
// Is the view now checked?
boolean checked = ((RadioButton) view).isChecked();
// Check which RadioButton was clicked
switch(view.getId()) {
case R.id.chk1:
if (checked)
// Do your coding
else
// Do your coding
break;
// Perform your logic
}
}
37. RadioButton and RadioGroup
Define RadioButton Click Event in Activity File
In android, we can define RadioButton click event programmatically in Activity file rather than XML layout
file.
To define RadioButton click event programmatically, create View.OnClickListener object and assign it to
the button by calling setOnClickListener(View.OnClickListener) like as shown below.
RadioButton rdb = (RadioButton) findViewById(R.id.radiobutton1);
rdb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = ((RadioButton) v).isChecked();
// Check which radiobutton was pressed
if (checked){
// Do your coding
}
else{
// Do your coding
}
}
});
38. RadioButton and RadioGroup
Android RadioButton Control Attributes
Attribute Description
android:id It is used to uniquely identify the control
android:checked It is used to specify the current state of radio button
android:gravity It is used to specify how to align the text like left, right, center, top, etc.
android:text It is used to set the text for the radio button.
android:textColor It is used to change the color of text.
android:textSize It is used to specify the size of the text.
android:textStyle It is used to change the style (bold, italic, bolditalic) of text.
android:background It is used to set the background color for radio button control.
android:padding It is used to set the padding from left, right, top and bottom.
android:onClick It’s the name of the method to invoke when the radio button clicked.
android:visibility It is used to control the visibility of control.
39. ProgressBar
In android, ProgressBar is a user interface control that is used to indicate the progress of an operation. For
example, downloading a file, uploading a file.
Following is the pictorial representation of using a different type of progress bars in android applications.
By default the ProgressBar will be displayed as a spinning wheel, in case if we want to show it like a horizontal bar
then we need to change the style property to horizontal like style="?android:attr/progressBarStyleHorizontal".
40. ProgressBar Create Android ProgressBar in XML Layout File
In android, we can create ProgressBar in XML layout file using <ProgressBar> element with different attributes like as
shown below
<ProgressBar
android:id="@+id/pBar3"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:minWidth="250dp"
android:max="100"
android:indeterminate="true"
android:progress="1" />
attribute Description
android:id It is used to uniquely identify the control
android:minHeight It is used to set the height of the progress bar.
android:minWidth It is used to set the width of the progress bar.
android:max It is used to set the maximum value of the progress bar.
android:progress It is used to set the default progress value between 0 and max. It must be an integer value.
41. ProgressBar Create Android ProgressBar in XML Layout File
Android ProgressBar with Determinate Mode
In android, the ProgressBar supports two types of modes to show the progress, those
are Determinate and Indeterminate.
Generally, we use the Determinate progress mode in progress bar when we want to show the quantity of progress has
occurred. For example, the percentage of file downloaded, number of records inserted into a database, etc.
To use Determinate progress, we need to set the style of the progress bar
to Widget_ProgressBar_Horizontal or progressBarStyleHorizontal and set the amount of progress
using android:progress attribute.
Following is the example which shows a Determinate progress bar that is 50% complete.
<ProgressBar
android:id="@+id/pBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:max="100"
android:progress="50" />
By using setProgress(int) method, we can update the
percentage of progress displayed in app or by calling
incrementProgressBy(int) method, we can increase
the value of current progress completed based on
our requirements.
Generally, when the progress value reaches 100
then the progress bar is full. By using android:max
attribute we can adjust this default value.
42. ProgressBar Create Android ProgressBar in XML Layout File
Android ProgressBar with Indeterminate Mode
In android, the ProgressBar supports two types of modes to show the progress, those
are Determinate and Indeterminate.
Generally, we use the Indeterminate progress mode in progress bar when we don’t know how long an operation will take
or how much work has done.
In indeterminate mode the actual progress will not be shown, only the cyclic animation will be shown to indicate that some
progress is happing like as shown in the above progress bar loading images.
By using progressBar.setIndeterminate(true) in activity file programmatically or using android:indeterminate = “true”
attribute in XML layout file, we can enable Indeterminate progress mode.
Following is the example to set Indeterminate progress mode in an XML layout file.
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"/>
43. ProgressBar
Android ProgressBar Control Attributes
Attribute Description
android:id It is used to uniquely identify the control
android:max It is used to specify the maximum value of the progress can take
android:progress It is used to specify default progress value.
android:background It is used to set the background color for a progress bar.
android:indeterminate It is used to enable the indeterminate progress mode.
android:padding It is used to set the padding for left, right, top or bottom of a progress bar.
44. Android DatePicker with Examples
In android, DatePicker is a control that will allow users to select the date by a day, month and year in our
application user interface.
If we use DatePicker in our application, it will ensure that the users will select a valid date.
Following is the pictorial representation of using a datepicker control in android applications.
45. Android DatePicker with Examples
Generally, in android DatePicker available in two modes, one is to show the complete calendar and another one
is to show the dates in spinner view.
Create Android DatePicker in XML Layout File
In android, we can create a DatePicker in XML layout file using <DatePicker> element with different attributes
like as shown below
<DatePicker android:id="@+id/datePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
The above code snippet will return the DatePicker in android like as shown below
46. Android DatePicker with Examples
Android DatePicker with Spinner Mode
If we want to show the DatePicker in spinner format like showing day, month and year separately to select the
date, then by using DatePicker android:datePickerMode attribute we can achieve this.
Following is the example of showing the DatePicker in Spinner mode.
<DatePicker
android:id="@+id/datePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:datePickerMode="spinner"
android:calendarViewShown="false"/>
The above code will return the DatePicker like as shown below
47. Android DatePicker with Examples
Android DatePicker Control Attributes
Attribute Description
android:id It is used to uniquely identify the control
android:datePickerMode It is used to specify datepicker mode either spinner or
calendar
android:background It is used to set the background color for the date
picker.
android:padding It is used to set the padding for left, right, top or
bottom of the date picker.
Android DatePicker Example: https://www.tutlane.com/tutorial/android/android-datepicker-with-examples