Beruflich Dokumente
Kultur Dokumente
Q.1 Write structure and XML code for the following: CO2/CO3
(i) Linear Layout
(ii) Relative Layout
(iii) Frame Layout
Ans 1. The structure and xml code for the following is:
1.Linear Layout: A Layout that arranges its children during a single column or one row. The direction
of the row are often set by calling setOrientation()/android orientation=”verticle”. you'll also specify
gravity, which specifies the alignment of all the kid elements by calling setGravity() or specify that
specific children grow to refill any remaining space within the layout by setting the load member of
LinearLayout.LayoutParams. The default orientation is horizontal.
2. Relative Layout: Relative Layout may be a view group that displays child views in relative
positions. The position of each view are often specified as relative to sibling elements (such on the
left-of or below another view) or in positions relative to the parent Relative Layout area (such as
aligned to rock bottom , left or centre )
3. Frame Layout: FrameLayout is meant to dam out a neighborhood on the screen to display one
item. Generally, FrameLayout should be wont to hold one child view, because it'll be difficult to
rearrange child views during how that's scalable to different screen sizes without the youngsters
overlapping one another . You can, however, add multiple children to a FrameLayout and control
their position within the FrameLayout by assigning gravity to each child, using the
android:layout_gravity attribute.
Child views are drawn during a stack, with the foremost recently added child on top. the dimensions
of the FrameLayout is that the dimensions of its largest child (plus padding), visible or not (if the
FrameLayout's parent permits). Views that are View.GONE are used for sizing as long as
setConsiderGoneChildrenWhenMeasuring() is close to true
.
Q.2 Write steps to a notification and how to add sound to the Notification
CO4
Alert Dialog
•A dialog that can manage zero, one, two or three buttons.
•It can also manage a list of selectable items that can include checkboxes or radio buttons.
•The Alert Dialog is capable of constructing most dialog user interfaces and is the suggested dialog
type. •Alert Dialog class is a subclass of Dialog class and has a nested subclass.
•AlertDialog.Builder to construct a dialog.
Progress Dialog
A Progress Dialog is an extension of the Alert Dialog class that can display a progress animation in
the form of a spinning wheel The dialog can also provide buttons, such as one to cancel a download
Progress Dialog dialog = ProgressDialog.show) MyActivity.this,"" , "Loading .Please wait"..., true);
DatePickerDialog
The DatePickerDialog class consists of a 5 argument constructor with the parameters listed below.
int year : It will be store the current selected year from the dialog
int monthOfYear : It will be store the current selected month from the dialog
int dayOfMonth : It will be store the current selected day from the dialog
1. int mYear : It shows the the current year that’s visible when the dialog pops up
2. int mMonth : It shows the the current month that’s visible when the dialog pops up
3. int mDay : It shows the the current day that’s visible when the dialog pops up
code-
Public DatePickerDialog
( Context context,
DatePickerDialog.OnDateSetListener callback,
int year,
int monthOfYear,
int dayOfMonth )
Ans 4.
Menus Items are often grouped together by assigning all a group ID.
1. Optional Menus: the choices menu is that the primary collection of menu items for an activity.
It's where you ought to place actions that have a worldwide impact on the app, like "Search,"
"Compose email," and "Settings."
2. Sub Menus: Sub menu may be a floating menu, it are often a toddler menu of options menu
or context menu. - It supports checkboxes, radio buttons and shortcut keys. - It doesn't
support item icons, or nested sub menus.
3. Context Menu: A context menu may be a floating menu that appears when the user
performs a long-click on a component . It provides actions that affect the chosen content or
context frame.
Q.5 What classes are provided by Android framework to play audio and
video files? What are the uses of these classes? How audio file can be
played through media player? Where these audio file need to be kept?
Android provides some ways to regulate playback of audio/video files and streams. One of this
manner is through a category called MediaPlayer.Android is providing MediaPlayer class to
access built-in mediaplayer services like playing audio,video e.t.c. In order to use
MediaPlayer, we've to call a static Method create() of this class. This method returns an
instance of MediaPlayer class. Its syntax is as follows –
Once Mediaplayer object is created. These methods can call some methods to start or stop the are
listed below.
mediaPlayer.start();
mediaPlayer.pause();
On call to start() method, the music will start playing from the start . If this method is
named again after the pause() method, the music would start playing from where it's left and
not from the start .
6.release()- This method releases any resource attached with MediaPlayer object
7. setVolume(float leftVolume, float rightVolume)- This method sets the up down volume for
this player
9. selectTrack(int index)- This method takes an integer, and choose the track from the
list thereon particular index
We can play and control the audio files in android by the assistance of MediaPlayer class.
The android.media.MediaPlayer class is employed to regulate the audio or video files.
The audio files are often moved to a folder named raw which should be created within the res
folder.