SlideShare a Scribd company logo
USER INTERFACE 
1 
Android application development
USER INTERFACE 
2 
The Android Widget Toolbox 
1. TextView 
2. EditText 
3. Spinner 
4. Button 
5. CheckBox 
6. RadioButton 
7. DatePicker 
8. TimePicker 
Layouts 
1. Frame Layout 
2. Linear Layout 
3. Relative Layout 
4. Table Layout 
5. Absolute Layout 
6. Grid Layout 
7. Tab Layout
USER INTERFACE 
Android Widget Toolbox 
Date Picker Tutorial 
To provide a widget for selecting a date, use the DatePicker widget, which allows 
the user to 
select the month, day, and year, in a familiar interface. 
1. We’ll create a DatePickerDialog, which presents the date picker in a floating 
3 
dialog box at the press of a button. 
2. When the date is set by the user, a TextView will update with the new date.
USER INTERFACE 
4 
Android Widget Toolbox 
Date Picker Tutorial (Cont.) 
1. Start a new project named HelloDatePicker. 
2. Open the res/layout/main.xml file and insert the following: 
This creates a basic LinearLayout with a TextView that will display the date and 
a Button that will open the DatePickerDialog.
USER INTERFACE 
5 
Android Widget Toolbox 
Date Picker Tutorial (Cont.) 
3. Open HelloDatePicker.java 
4. add the following members to the class
USER INTERFACE 
6 
Android Widget Toolbox 
Date Picker Tutorial (Cont.) 
5. Now we add following code in onCreate() method to capture View 
elements and add listener to the Button. 
6. Now we show the dialog in button action
USER INTERFACE 
7 
Android Widget Toolbox 
Date Picker Tutorial (Cont.) 
1. First, the content is set to the main.xml layout. 
2. Then the TextView and Button elements are captured from the layout with 
findViewById(int). 
3. A new View.OnClickListener is created for the Button, so that when it is clicked, 
it will call showDialog(int), passing the unique integer ID for the date picker 
dialog. 
4. Using showDialog(int) allows the Activity to manage the life-cycle of the dialog 
and will call the onCreateDialog(int) callback method to request the Dialog that 
should be displayed.
USER INTERFACE 
8 
Android Widget Toolbox 
Date Picker Tutorial (Cont.) 
5. Now we need to add a DateSetListener which will invoke when user selects a date
USER INTERFACE 
9 
Android Widget Toolbox 
Date Picker Tutorial (Cont.) 
6. Now we see
USER INTERFACE 
10 
Android Widget Toolbox 
Date Picker Tutorial (Cont.) 
6. Now we add this method to show the date in display TextView
USER INTERFACE 
11 
Android Widget Toolbox 
Date Picker Tutorial (Cont.) 
7. We set the selected date in DatePicker and get it from callback
USER INTERFACE 
12 
Android Widget Toolbox 
Date Picker Tutorial (Cont.) 
8. We add the following code to initiate with current date
USER INTERFACE 
13 
Android Widget Toolbox 
Date Picker Tutorial (Cont.) 
2. onCreate
USER INTERFACE 
14 
Android Widget Toolbox 
Date Picker Tutorial (Cont.) 
3. callback method for creating dialog 
4. Initialize a new 
DatePickerDialog.OnDateSetListen 
er 
for when the user has set the date 
(by clicking the "Set" button)
USER INTERFACE 
15 
Android Widget Toolbox 
Date Picker Tutorial (Cont.)
USER INTERFACE 
Android Widget Toolbox 
Time Picker Tutorial 
To provide a widget for selecting a date, use the TimePicker widget, which allows 
the user to 
select the hour and minute in a familiar interface. 
1. We’ll create a TimePickerDialog, which presents the date picker in a floating 
16 
dialog box at the press of a button. 
2. When the time is set by the user, a TextView will update with the new time. 
Do it yourself
USER INTERFACE 
17 
Android Widget Toolbox 
Time Picker Tutorial (Contd.) 
Hints:
USER INTERFACE 
18 
Android Widget Toolbox 
Spinner Tutorial 
Spinner is a widget similar to a drop-down list for selecting items. 
1. In this tutorial, you'll create a simple spinner widget that displays a list of planets. 
2. When one is selected, a toast message will display the selected item.
USER INTERFACE 
19 
Android Widget Toolbox 
Spinner Tutorial (Contd.) 
1. Start a new project named HelloSpinner 
2. Open the res/layout/main.xml file and insert the following: 
Notice that the TextView's android:text attribute and the Spinner's android:prompt attribute 
both reference the same string resource. This text behaves as a title for the widget. When 
applied to the Spinner, the title text will appear in the selection dialog that appears upon 
selecting the widget.
USER INTERFACE 
20 
Android Widget Toolbox 
Spinner Tutorial (Contd.) 
3. Create a strings.xml file in res/values/ and edit the file to look like this: 
The <string> element defines the title string referenced by the TextView and Spinner in 
the layout above. The <string-array element defines the list of strings that will be displayed 
as the list in the Spinner widget.
USER INTERFACE 
21 
Android Widget Toolbox 
Spinner Tutorial (Contd.) 
4. Now open the HelloSpinner.java file and insert the following code for 
the onCreate() method: 
a. After the main.xml layout is set as the content view, the Spinner widget is captured from 
the layout with findViewById(int). 
b. The createFromResource() method then creates a new ArrayAdapter, which binds each item 
in the string array to the initial appearance for the Spinner 
c. TheR.array.planets_array ID references the string-array defined above and the 
android.R.layout.simple_spinner_item ID references a layout for the standard spinner 
appearance, defined by the platform.
USER INTERFACE 
22 
Android Widget Toolbox 
Spinner Tutorial (Contd.) 
5. Now create a nested class that implements AdapterView.OnItemSelectedListener. 
This will provide a callback method that will notify your application when an item has 
been selected from the Spinner. Here's what this class should look like 
The AdapterView.OnItemSelectedListener requires the onItemSelected() and 
onNothingSelected() callback methods.
USER INTERFACE 
23 
Android Widget Toolbox 
Spinner Tutorial (Contd.) 
6. Now the MyOnItemSelectedListener needs to be applied to the Spinner. 
Go back to the onCreate() method and add the following line to the end:
USER INTERFACE 
24 
Android Widget Toolbox 
Spinner Tutorial (Contd.) 
Run the application
USER INTERFACE 
Android Widget Toolbox 
Form Elements Tutorial 
This tutorial introduces a variety of widgets that are useful when creating forms, 
25 
1. image buttons, 
2. text fields, 
3. checkboxes, 
4. radio buttons, 
5. Toggle buttons, 
6. Rating bar
USER INTERFACE 
26 
Android Widget Toolbox 
Form Elements Tutorial (Contd.) 
1. Start a new project named HelloFormStuff. 
2. Create a basic LinearLayout in res/layout/main.xml 
3. onCreate()
USER INTERFACE 
We’ll create an image button with 3 states Using the Button widget and an XML file 
27 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Custom Button 
Normal Focused Pressed 
that defines three different images to use 
for the different button states. When the 
button is pressed, a short message will be 
displayed. 
1. Copy the images on the right into the res/drawable/ directory of your project. These will 
be used for the different button states. 
2. Create a new file in the res/drawable/ directory named android_button.xml. 
Insert the following XML: 
This defines a single drawable resource, which will change its image based on the 
current state of the button.
USER INTERFACE 
28 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Custom Button 
3. Open the res/layout/main.xml file and add the Button element: 
The android:background attribute specifies the drawable 
resource to use for the button background (which, when saved 
at res/drawable/android.xml, is referenced as @drawable/android). This replaces the 
normal background image used for buttons throughout the system. In order for the 
drawable to change its image based on the button state, the image must be applied to 
the background
USER INTERFACE 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Custom Button 
4. o make the button do something when pressed, add the following code at the end of the 
onCreate() method: 
29 
Normal Pressed After Pressed
USER INTERFACE 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Edit Text 
In this section, you will create a text field for user input, using the EditText widget. Once text 
has been entered into the field, the "Enter" key will display the text in a toast message. 
1. Open the res/layout/main.xml file and add the EditText element (inside the LinearLayout): 
30 
2.
USER INTERFACE 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Edit Text 
2. To do something with the text that the user types, add the following code to the 
end of the onCreate() method: 
31
USER INTERFACE 
32 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Edit Text
USER INTERFACE 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Check Box 
In this section, you will create a checkbox for selecting items, using the CheckBox widget. 
When the checkbox is pressed, a toast message will indicate the current state of the checkbox. 
1. Open the res/layout/main.xml file and add the CheckBox element (inside the LinearLayout): 
33
USER INTERFACE 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Check Box 
2. To do something when the state is changed, add the following code to the end 
of the onCreate() method: 
34
USER INTERFACE 
35 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Check Box
USER INTERFACE 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Radio Button 
In this section, you will create two mutually-exclusive radio buttons (enabling one disables the 
other), using the RadioGroup and RadioButton widgets. 
When either radio button is pressed, a toast message will be displayed. 
1. Open the res/layout/main.xml file and add two RadioButtons, nested in a RadioGroup 
(inside the LinearLayout): 
It's important that the RadioButtons are grouped together by the RadioGroup element so 
that no more than one can be selected at a time. This logic is automatically handled by the 
Android system. When one RadioButton within a group is selected, all others are 
automatically deselected 
36
USER INTERFACE 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Radio Button 
2. To do something when each RadioButton is selected, you need 
an View.OnClickListener. In this case, you want the listener to be re-usable, so add 
the following code to create a new member in the HelloFormStuff Activity 
37 
3. Now, at the bottom of the onCreate() method, add the following:
USER INTERFACE 
38 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Radio Button
USER INTERFACE 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Toggle Button 
In this section, you'll create a button used specifically for toggling between two states, using 
the ToggleButton widget. This widget is an excellent alternative to radio buttons if you have 
two simple states that are mutually exclusive ("on" and "off", for example). 
1. Open the res/layout/main.xml file and add the ToggleButton element (inside the 
LinearLayout): 
39
USER INTERFACE 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Toggle Button 
2. To do something when the state is changed, add the following code to the end of the 
onCreate() method: 
This captures the ToggleButton element from the layout, then adds an View.OnClickListener. 
The View.OnClickListener must implement the onClick(View) callback method, which defines 
the action to perform when the button is clicked. In this example, the callback method checks 
the new state of the button, then shows a Toast message that indicates the current state. 
40
USER INTERFACE 
41 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Toggle Button
USER INTERFACE 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Rating Bar 
In this section, you'll create a widget that allows the user to provide a rating, with the 
RatingBar widget. 
1. Open the res/layout/main.xml file and add the RatingBar element (inside the 
LinearLayout): 
2. To do something when a new rating has been set, add the following code to 
42 
the end of the onCreate() method:
USER INTERFACE 
43 
Android Widget Toolbox 
Form Elements Tutorial (Contd.)- Rating Bar
Thank You 
44

More Related Content

What's hot

Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Ahsanul Karim
 
android activity
android activityandroid activity
android activityDeepa Rani
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
Prawesh Shrestha
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & views
ma-polimi
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI WidgetsAhsanul Karim
 
Android app development ppt
Android app development pptAndroid app development ppt
Android app development ppt
saitej15
 
Types of Mobile Applications
Types of Mobile ApplicationsTypes of Mobile Applications
Types of Mobile Applications
Jawaher Abdulwahab Fadhil
 
Introduction to Android ppt
Introduction to Android pptIntroduction to Android ppt
Introduction to Android ppt
Taha Malampatti
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
Aakash Ugale
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologies
jerry vasoya
 
Layouts in android
Layouts in androidLayouts in android
Layouts in android
Durai S
 
android layouts
android layoutsandroid layouts
android layoutsDeepa Rani
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
Soham Patel
 
Java swing
Java swingJava swing
Java swing
Apurbo Datta
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
gebrsh
 
Android ui dialog
Android ui dialogAndroid ui dialog
Android ui dialogKrazy Koder
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
Sourabh Sahu
 

What's hot (20)

Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)
 
android activity
android activityandroid activity
android activity
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
Android Services
Android ServicesAndroid Services
Android Services
 
AndroidManifest
AndroidManifestAndroidManifest
AndroidManifest
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & views
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
 
Android app development ppt
Android app development pptAndroid app development ppt
Android app development ppt
 
Types of Mobile Applications
Types of Mobile ApplicationsTypes of Mobile Applications
Types of Mobile Applications
 
Introduction to Android ppt
Introduction to Android pptIntroduction to Android ppt
Introduction to Android ppt
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologies
 
Layouts in android
Layouts in androidLayouts in android
Layouts in android
 
android layouts
android layoutsandroid layouts
android layouts
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
 
Java swing
Java swingJava swing
Java swing
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Android Threading
Android ThreadingAndroid Threading
Android Threading
 
Android ui dialog
Android ui dialogAndroid ui dialog
Android ui dialog
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 

Similar to Android UI

Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Ahsanul Karim
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Ahsanul Karim
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAhsanul Karim
 
Notes Unit4.pptx
Notes Unit4.pptxNotes Unit4.pptx
Notes Unit4.pptx
MIT Autonomous Aurangabad
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
Shrijan Tiwari
 
Android App Development 03 : Widget &amp; UI
Android App Development 03 : Widget &amp; UIAndroid App Development 03 : Widget &amp; UI
Android App Development 03 : Widget &amp; UIAnuchit Chalothorn
 
Intake 38 9
Intake 38 9Intake 38 9
Intake 38 9
Mahmoud Ouf
 
Intake 37 9
Intake 37 9Intake 37 9
Intake 37 9
Mahmoud Ouf
 
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docx
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docxMicrosoft Visual C# 2012- An introduction to object-oriented programmi.docx
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docx
scroghamtressie
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
Denis Minja
 
Android session 3
Android session 3Android session 3
Android session 3
Ahesanali Suthar
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
kirupasuchi1996
 
lec 9.pptx
lec 9.pptxlec 9.pptx
lec 9.pptx
MaheshSharan
 
Notification android
Notification androidNotification android
Notification android
ksheerod shri toshniwal
 
Android action bar and notifications-chapter16
Android action bar and notifications-chapter16Android action bar and notifications-chapter16
Android action bar and notifications-chapter16
Dr. Ramkumar Lakshminarayanan
 
ANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.doc
Palakjaiswal43
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
Isham Rashik
 
Activity & Shared Preference
Activity & Shared PreferenceActivity & Shared Preference
Activity & Shared Preference
nationalmobileapps
 

Similar to Android UI (20)

Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form Widgets
 
Notes Unit4.pptx
Notes Unit4.pptxNotes Unit4.pptx
Notes Unit4.pptx
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Android App Development 03 : Widget &amp; UI
Android App Development 03 : Widget &amp; UIAndroid App Development 03 : Widget &amp; UI
Android App Development 03 : Widget &amp; UI
 
UIAutomator
UIAutomatorUIAutomator
UIAutomator
 
Intake 38 9
Intake 38 9Intake 38 9
Intake 38 9
 
Intake 37 9
Intake 37 9Intake 37 9
Intake 37 9
 
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docx
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docxMicrosoft Visual C# 2012- An introduction to object-oriented programmi.docx
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docx
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
Android
AndroidAndroid
Android
 
Android session 3
Android session 3Android session 3
Android session 3
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
 
lec 9.pptx
lec 9.pptxlec 9.pptx
lec 9.pptx
 
Notification android
Notification androidNotification android
Notification android
 
Android action bar and notifications-chapter16
Android action bar and notifications-chapter16Android action bar and notifications-chapter16
Android action bar and notifications-chapter16
 
ANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.doc
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
 
Activity & Shared Preference
Activity & Shared PreferenceActivity & Shared Preference
Activity & Shared Preference
 

More from nationalmobileapps

Fragment
Fragment Fragment
Android Location Api
Android Location ApiAndroid Location Api
Android Location Api
nationalmobileapps
 
Play Store
Play StorePlay Store
Play Store
nationalmobileapps
 
GCM (push notification)
GCM (push notification)GCM (push notification)
GCM (push notification)
nationalmobileapps
 
Android Sensor
Android SensorAndroid Sensor
Android Sensor
nationalmobileapps
 
Ad Mob
Ad MobAd Mob
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
nationalmobileapps
 
Google Map V2
Google Map V2Google Map V2
Google Map V2
nationalmobileapps
 
Database
DatabaseDatabase
Intent
IntentIntent
Support Multiple Screen
Support Multiple ScreenSupport Multiple Screen
Support Multiple Screen
nationalmobileapps
 
Listview
ListviewListview
Event Handling
Event HandlingEvent Handling
Event Handling
nationalmobileapps
 
Mobile Application capacity building activities
Mobile Application capacity building activities Mobile Application capacity building activities
Mobile Application capacity building activities
nationalmobileapps
 
Future of Smart phone in Bangladesh
Future of Smart phone in Bangladesh Future of Smart phone in Bangladesh
Future of Smart phone in Bangladesh
nationalmobileapps
 

More from nationalmobileapps (16)

Fragment
Fragment Fragment
Fragment
 
Android Location Api
Android Location ApiAndroid Location Api
Android Location Api
 
Play Store
Play StorePlay Store
Play Store
 
GCM (push notification)
GCM (push notification)GCM (push notification)
GCM (push notification)
 
Android Sensor
Android SensorAndroid Sensor
Android Sensor
 
Ad Mob
Ad MobAd Mob
Ad Mob
 
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
 
Google Map V2
Google Map V2Google Map V2
Google Map V2
 
Database
DatabaseDatabase
Database
 
Intent
IntentIntent
Intent
 
Support Multiple Screen
Support Multiple ScreenSupport Multiple Screen
Support Multiple Screen
 
Listview
ListviewListview
Listview
 
Event Handling
Event HandlingEvent Handling
Event Handling
 
Project anatomy & hello world
Project anatomy & hello worldProject anatomy & hello world
Project anatomy & hello world
 
Mobile Application capacity building activities
Mobile Application capacity building activities Mobile Application capacity building activities
Mobile Application capacity building activities
 
Future of Smart phone in Bangladesh
Future of Smart phone in Bangladesh Future of Smart phone in Bangladesh
Future of Smart phone in Bangladesh
 

Recently uploaded

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 

Recently uploaded (20)

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 

Android UI

  • 1. USER INTERFACE 1 Android application development
  • 2. USER INTERFACE 2 The Android Widget Toolbox 1. TextView 2. EditText 3. Spinner 4. Button 5. CheckBox 6. RadioButton 7. DatePicker 8. TimePicker Layouts 1. Frame Layout 2. Linear Layout 3. Relative Layout 4. Table Layout 5. Absolute Layout 6. Grid Layout 7. Tab Layout
  • 3. USER INTERFACE Android Widget Toolbox Date Picker Tutorial To provide a widget for selecting a date, use the DatePicker widget, which allows the user to select the month, day, and year, in a familiar interface. 1. We’ll create a DatePickerDialog, which presents the date picker in a floating 3 dialog box at the press of a button. 2. When the date is set by the user, a TextView will update with the new date.
  • 4. USER INTERFACE 4 Android Widget Toolbox Date Picker Tutorial (Cont.) 1. Start a new project named HelloDatePicker. 2. Open the res/layout/main.xml file and insert the following: This creates a basic LinearLayout with a TextView that will display the date and a Button that will open the DatePickerDialog.
  • 5. USER INTERFACE 5 Android Widget Toolbox Date Picker Tutorial (Cont.) 3. Open HelloDatePicker.java 4. add the following members to the class
  • 6. USER INTERFACE 6 Android Widget Toolbox Date Picker Tutorial (Cont.) 5. Now we add following code in onCreate() method to capture View elements and add listener to the Button. 6. Now we show the dialog in button action
  • 7. USER INTERFACE 7 Android Widget Toolbox Date Picker Tutorial (Cont.) 1. First, the content is set to the main.xml layout. 2. Then the TextView and Button elements are captured from the layout with findViewById(int). 3. A new View.OnClickListener is created for the Button, so that when it is clicked, it will call showDialog(int), passing the unique integer ID for the date picker dialog. 4. Using showDialog(int) allows the Activity to manage the life-cycle of the dialog and will call the onCreateDialog(int) callback method to request the Dialog that should be displayed.
  • 8. USER INTERFACE 8 Android Widget Toolbox Date Picker Tutorial (Cont.) 5. Now we need to add a DateSetListener which will invoke when user selects a date
  • 9. USER INTERFACE 9 Android Widget Toolbox Date Picker Tutorial (Cont.) 6. Now we see
  • 10. USER INTERFACE 10 Android Widget Toolbox Date Picker Tutorial (Cont.) 6. Now we add this method to show the date in display TextView
  • 11. USER INTERFACE 11 Android Widget Toolbox Date Picker Tutorial (Cont.) 7. We set the selected date in DatePicker and get it from callback
  • 12. USER INTERFACE 12 Android Widget Toolbox Date Picker Tutorial (Cont.) 8. We add the following code to initiate with current date
  • 13. USER INTERFACE 13 Android Widget Toolbox Date Picker Tutorial (Cont.) 2. onCreate
  • 14. USER INTERFACE 14 Android Widget Toolbox Date Picker Tutorial (Cont.) 3. callback method for creating dialog 4. Initialize a new DatePickerDialog.OnDateSetListen er for when the user has set the date (by clicking the "Set" button)
  • 15. USER INTERFACE 15 Android Widget Toolbox Date Picker Tutorial (Cont.)
  • 16. USER INTERFACE Android Widget Toolbox Time Picker Tutorial To provide a widget for selecting a date, use the TimePicker widget, which allows the user to select the hour and minute in a familiar interface. 1. We’ll create a TimePickerDialog, which presents the date picker in a floating 16 dialog box at the press of a button. 2. When the time is set by the user, a TextView will update with the new time. Do it yourself
  • 17. USER INTERFACE 17 Android Widget Toolbox Time Picker Tutorial (Contd.) Hints:
  • 18. USER INTERFACE 18 Android Widget Toolbox Spinner Tutorial Spinner is a widget similar to a drop-down list for selecting items. 1. In this tutorial, you'll create a simple spinner widget that displays a list of planets. 2. When one is selected, a toast message will display the selected item.
  • 19. USER INTERFACE 19 Android Widget Toolbox Spinner Tutorial (Contd.) 1. Start a new project named HelloSpinner 2. Open the res/layout/main.xml file and insert the following: Notice that the TextView's android:text attribute and the Spinner's android:prompt attribute both reference the same string resource. This text behaves as a title for the widget. When applied to the Spinner, the title text will appear in the selection dialog that appears upon selecting the widget.
  • 20. USER INTERFACE 20 Android Widget Toolbox Spinner Tutorial (Contd.) 3. Create a strings.xml file in res/values/ and edit the file to look like this: The <string> element defines the title string referenced by the TextView and Spinner in the layout above. The <string-array element defines the list of strings that will be displayed as the list in the Spinner widget.
  • 21. USER INTERFACE 21 Android Widget Toolbox Spinner Tutorial (Contd.) 4. Now open the HelloSpinner.java file and insert the following code for the onCreate() method: a. After the main.xml layout is set as the content view, the Spinner widget is captured from the layout with findViewById(int). b. The createFromResource() method then creates a new ArrayAdapter, which binds each item in the string array to the initial appearance for the Spinner c. TheR.array.planets_array ID references the string-array defined above and the android.R.layout.simple_spinner_item ID references a layout for the standard spinner appearance, defined by the platform.
  • 22. USER INTERFACE 22 Android Widget Toolbox Spinner Tutorial (Contd.) 5. Now create a nested class that implements AdapterView.OnItemSelectedListener. This will provide a callback method that will notify your application when an item has been selected from the Spinner. Here's what this class should look like The AdapterView.OnItemSelectedListener requires the onItemSelected() and onNothingSelected() callback methods.
  • 23. USER INTERFACE 23 Android Widget Toolbox Spinner Tutorial (Contd.) 6. Now the MyOnItemSelectedListener needs to be applied to the Spinner. Go back to the onCreate() method and add the following line to the end:
  • 24. USER INTERFACE 24 Android Widget Toolbox Spinner Tutorial (Contd.) Run the application
  • 25. USER INTERFACE Android Widget Toolbox Form Elements Tutorial This tutorial introduces a variety of widgets that are useful when creating forms, 25 1. image buttons, 2. text fields, 3. checkboxes, 4. radio buttons, 5. Toggle buttons, 6. Rating bar
  • 26. USER INTERFACE 26 Android Widget Toolbox Form Elements Tutorial (Contd.) 1. Start a new project named HelloFormStuff. 2. Create a basic LinearLayout in res/layout/main.xml 3. onCreate()
  • 27. USER INTERFACE We’ll create an image button with 3 states Using the Button widget and an XML file 27 Android Widget Toolbox Form Elements Tutorial (Contd.)- Custom Button Normal Focused Pressed that defines three different images to use for the different button states. When the button is pressed, a short message will be displayed. 1. Copy the images on the right into the res/drawable/ directory of your project. These will be used for the different button states. 2. Create a new file in the res/drawable/ directory named android_button.xml. Insert the following XML: This defines a single drawable resource, which will change its image based on the current state of the button.
  • 28. USER INTERFACE 28 Android Widget Toolbox Form Elements Tutorial (Contd.)- Custom Button 3. Open the res/layout/main.xml file and add the Button element: The android:background attribute specifies the drawable resource to use for the button background (which, when saved at res/drawable/android.xml, is referenced as @drawable/android). This replaces the normal background image used for buttons throughout the system. In order for the drawable to change its image based on the button state, the image must be applied to the background
  • 29. USER INTERFACE Android Widget Toolbox Form Elements Tutorial (Contd.)- Custom Button 4. o make the button do something when pressed, add the following code at the end of the onCreate() method: 29 Normal Pressed After Pressed
  • 30. USER INTERFACE Android Widget Toolbox Form Elements Tutorial (Contd.)- Edit Text In this section, you will create a text field for user input, using the EditText widget. Once text has been entered into the field, the "Enter" key will display the text in a toast message. 1. Open the res/layout/main.xml file and add the EditText element (inside the LinearLayout): 30 2.
  • 31. USER INTERFACE Android Widget Toolbox Form Elements Tutorial (Contd.)- Edit Text 2. To do something with the text that the user types, add the following code to the end of the onCreate() method: 31
  • 32. USER INTERFACE 32 Android Widget Toolbox Form Elements Tutorial (Contd.)- Edit Text
  • 33. USER INTERFACE Android Widget Toolbox Form Elements Tutorial (Contd.)- Check Box In this section, you will create a checkbox for selecting items, using the CheckBox widget. When the checkbox is pressed, a toast message will indicate the current state of the checkbox. 1. Open the res/layout/main.xml file and add the CheckBox element (inside the LinearLayout): 33
  • 34. USER INTERFACE Android Widget Toolbox Form Elements Tutorial (Contd.)- Check Box 2. To do something when the state is changed, add the following code to the end of the onCreate() method: 34
  • 35. USER INTERFACE 35 Android Widget Toolbox Form Elements Tutorial (Contd.)- Check Box
  • 36. USER INTERFACE Android Widget Toolbox Form Elements Tutorial (Contd.)- Radio Button In this section, you will create two mutually-exclusive radio buttons (enabling one disables the other), using the RadioGroup and RadioButton widgets. When either radio button is pressed, a toast message will be displayed. 1. Open the res/layout/main.xml file and add two RadioButtons, nested in a RadioGroup (inside the LinearLayout): It's important that the RadioButtons are grouped together by the RadioGroup element so that no more than one can be selected at a time. This logic is automatically handled by the Android system. When one RadioButton within a group is selected, all others are automatically deselected 36
  • 37. USER INTERFACE Android Widget Toolbox Form Elements Tutorial (Contd.)- Radio Button 2. To do something when each RadioButton is selected, you need an View.OnClickListener. In this case, you want the listener to be re-usable, so add the following code to create a new member in the HelloFormStuff Activity 37 3. Now, at the bottom of the onCreate() method, add the following:
  • 38. USER INTERFACE 38 Android Widget Toolbox Form Elements Tutorial (Contd.)- Radio Button
  • 39. USER INTERFACE Android Widget Toolbox Form Elements Tutorial (Contd.)- Toggle Button In this section, you'll create a button used specifically for toggling between two states, using the ToggleButton widget. This widget is an excellent alternative to radio buttons if you have two simple states that are mutually exclusive ("on" and "off", for example). 1. Open the res/layout/main.xml file and add the ToggleButton element (inside the LinearLayout): 39
  • 40. USER INTERFACE Android Widget Toolbox Form Elements Tutorial (Contd.)- Toggle Button 2. To do something when the state is changed, add the following code to the end of the onCreate() method: This captures the ToggleButton element from the layout, then adds an View.OnClickListener. The View.OnClickListener must implement the onClick(View) callback method, which defines the action to perform when the button is clicked. In this example, the callback method checks the new state of the button, then shows a Toast message that indicates the current state. 40
  • 41. USER INTERFACE 41 Android Widget Toolbox Form Elements Tutorial (Contd.)- Toggle Button
  • 42. USER INTERFACE Android Widget Toolbox Form Elements Tutorial (Contd.)- Rating Bar In this section, you'll create a widget that allows the user to provide a rating, with the RatingBar widget. 1. Open the res/layout/main.xml file and add the RatingBar element (inside the LinearLayout): 2. To do something when a new rating has been set, add the following code to 42 the end of the onCreate() method:
  • 43. USER INTERFACE 43 Android Widget Toolbox Form Elements Tutorial (Contd.)- Rating Bar