Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Lecture 04

GUI Widgets (Cont...)


Smart Application Development
Engr. Adeel Asghar
Lecturer
Department of Computer Science
NUML RWP
e-mail: adeel.asghar@numl.edu.pk
Menus
(link)
Menu: Common user interface component in many types of applications.
• For all menu types, Android provides a
standard XML format to define menu
items.

• Instead of building a menu in your


activity's code, you should define a
menu and all its items in an XML menu
resource.

https://developer.android.com/guide/topics/ui/menus.html
Action
Bar
Action bar: top-level menu of app functions
• replaces older "Menu" button
(which is now discouraged in Android3+)
• identifies current activity/app to user
• make common actions prominent and
available
• make less common actions available
through a drop-down menu

https://developer.android.com/guide/topics/ui/actionbar.html
Support for
Action Bar
• make activity class extend AppCompatActivity
– write methods: onCreateOptionsMenu,
onOptionsItemSelected

• declare the menu items in res/menu/menu_activity.xml


– decide which items have icons, which have text, which should appear in
main menu, which in "overflow" submenu
– need to place icon image files in res/drawable folder

• handle events
– write code in onOptionsItemSelected to check what option was
clicked and respond accordingly
Making Menu in
AppCompatActivity
Making Menu in
AppCompatActivity (Cont…)
Defining a Menu in XML
• Using a menu resource is a good practice for a few
reasons:
– It's easier to visualize the menu structure in XML.
– It separates the content for the menu from your
application's behavioral code.
– It allows you to create alternative menu configurations for
different platform versions, screen sizes, and other
configurations by leveraging the app resources framework.
Defining a Menu in XML
(Cont...)
Solution to Menu with Icons and
Text items
Rating Bar
(link)
A RatingBar is an extension of SeekBar and ProgressBar that
shows a rating in stars.

• The user can touch/drag or use


arrow keys to set the rating when
using the default size RatingBar.

• When using a RatingBar that


supports user interaction, placing
widgets to the left or right of the
RatingBar is discouraged.

https://developer.android.com/reference/android/widget/RatingBar.html
Ideas...!!
!

History Venture
Idea??

Idea??
Think!!
Idea?? Education
Silicon Valley
Module

Idea??
#Tag #Tag Idea??
Hangouts
Idea??

Idea??
Moasure – the smart tape
measure
Topics Covered

– http://developer.android.com/guide/topics
(mentioned in slides)
Any Question?

You might also like