android

Description: android
Number of Questions: 14
Created by:
Tags:
Attempted 0/13 Correct 0 Score 0

How to set the duration of the Toast by using Toast class?

  1. int Toast.dur=10;

  2. int dur=Toast(10);

  3. int dur=Toast.LENGTH_SHORT;

  4. int dur=Toast.LENGTH_SHORT(10);


Correct Option: C
Explanation:

There are two way to declare the duration of the Toast: int dur=Toast.LENGTH_SHORT; int dur=Toast.LENGTH_LONG;

Which of the following class is used to give a simple message that is flashed on the screen for a short time (5 to 10 seconds)

  1. Delay

  2. Toasts

  3. Toast

  4. Message Toast


Correct Option: B
Explanation:

The Toasts class is used to give a simple message that is flashed on the screen for a short time (5 to 10 seconds). A toast is the most basic and least intrusive notification.

To create a dialog, extend the _____________ class and implement either onCreateView or onCreateDialog method.

  1. Dialog

  2. DialogFormat

  3. DialogFragment

  4. DialogFrame


Correct Option: C
Explanation:

To create a dialog, extend the DialogFragment class and implement either onCreateView or onCreateDialog method.

How can avoid to creating anonymous classes for click handling?

  1. Implement the click interfaces in your activity and pass in this when registering a click listener.

  2. Extends the click interfaces in your activity and pass in this when registering a click listener.

  3. Implement the click listner interfaces in your activity and pass in this when registering a click listener.

  4. Implement the click interfaces in anywhere and pass in this when registering a click listener.


Correct Option: A
Explanation:

To avoid creating anonymous classes for click handling, you can Implement the click interfaces in your activity and pass in this when registering a click listener.

A long press is triggered when the user taps and holds on the screen. Long Presses are handled by registering an ___________________.

  1. onLongPress

  2. onPressListner

  3. onLongPressListener

  4. onLongClick


Correct Option: C
Explanation:

A long press is triggered when the user taps and holds on the screen. Long Presses are handled by registering an onLongPressListener.Other than the name, the setup of a long press listener is exactly the same a standard click listener.

_____________ introduced the Notification. Builder class for creating notification.

  1. Android 2.0

  2. Android 3.0

  3. Android 4.0

  4. Android 4.2


Correct Option: C
Explanation:

Android 3.0 introduced the Notification. Builder class for creating notification. This builder class replaces the existing constructor for the Notification class and makes creating notifications easier.

Which of the following method is called when the user taps the screen?

  1. onTouched

  2. onTapped

  3. onTap

  4. onTouch


Correct Option: D
Explanation:

When the user taps the screen, a touch event is fired and the corresponding onTouch method of the tapped view is called.

The process of converting a layout XML file into a hierarchy of views is called ________.

  1. Flating

  2. Inflating

  3. Tree

  4. Ladder


Correct Option: B
Explanation:

The process of converting a layout XML file into a hierarchy of views is called inflating. This is done using the layoutInflater class.

Like all other Android layouts, menus can be defined using ______.

  1. XML only

  2. Java Only

  3. XML or Java

  4. .Net


Correct Option: C
Explanation:

Like all other Android layouts, menus can be defined using XML or Java code. But it is better to use XML because we can quickly create the menu options and their order without any boilerplate code.

int icon=R.drawable.icon; CharSequence ticker = “Hello World”; Long cur=System.currentTimeMillis();

What are the correct sequence to send the above values to constructor of Notification?

  1. Notification notn=new Notification(icon,ticker,cur)

  2. Notification notn=new Notification(cur,ticker,icon)

  3. Notification notn=new Notification(icon,cur,ticker)

  4. Notification notn=new Notification(ticker,icon,cur)


Correct Option: A
Explanation:

The correct code for Notification is as follows: int icon=R.drawable.icon; CharSequence ticker = “Hello World”; Long cur=System.currentTimeMillis(); Notification notn=new Notification(icon,ticker,cur)

The onCreateOptionsMenu callback is called when the user ____________________.

  1. Click the screen

  2. Touch the menu

  3. Swap the screen

  4. Presses the menu button


Correct Option: D
Explanation:

The onCreateOptionsMenu callback is called when the user presses the menu button; this is where we create the menu by using the layout resource file.

When context menus triggered?

  1. By pressing button

  2. By pressing main menu

  3. By pressing a view

  4. By long-presses a view


Correct Option: D
Explanation:

Context menus work the same way as options menus but are triggered when the user long presses a view.

Which of the following Statements are correct: A. Use onCreateView to set the view hierarchy for the dialog. B. Use onCreateDialog to create a completely custom dialog.

  1. Both A and B

  2. Only A

  3. Only B

  4. Neither A nor B


Correct Option: A
Explanation:

Both statements are correct. By extending the  DialogFragment  class and implementing on onCreateView or onCreateDialog method, you can create the dialog. You can use onCreateView to set the view hierarchy for the dialog and onCreateDialog to create a completely custom dialog.

- Hide questions