Android Application Development v7.0

Page:    1 / 16   
Exam contains 228 questions

What two methods you have to override when implementing Android context menus?

  • A. onCreateOptionsMenu, onCreateContextMenu
  • B. onCreateContextMenu, onContextItemSelected
  • C. onCreateOptionsMenu, onOptionsItemSelected
  • D. onCreateOptionsMenu, onContextItemSelected


Answer : B

need to create context menu. For this need to override this method:
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.setHeaderTitle("My Context Menu"); menu.add(0, NEW_MENU_ITEM, 0, "new"); menu.add(0, SAVE_MENU_ITEM, 1, "save");
}
And last one need to handle menu clicks:
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
case NEW_MENU_ITEM:
doSomething();
break;
case SAVE_MENU_ITEM:
doSomething();
break;
}
return super.onContextItemSelected(item);
}
References:
https://thedevelopersinfo.wordpress.com/2009/11/06/using-context-menus-in-android/

What two methods you have to override when implementing Android option menus?

  • A. onCreateOptionsMenu, onCreateContextMenu
  • B. onCreateContextMenu, onContextItemSelected
  • C. onCreateOptionsMenu, onOptionsItemSelected
  • D. onCreateOptionsMenu, onContextItemSelected


Answer : C

To specify the options menu for an activity, override onCreateOptionsMenu().
When the user selects an item from the options menu (including action items in the app bar), the system calls your activity's onOptionsItemSelected() method.
This method passes the MenuItem selected. You can identify the item by calling getItemId(), which returns the unique ID for the menu item (defined by the android:id attribute in the menu resource or with an integer given to the add() method). You can match this ID against known menu items to perform the appropriate action. For example:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Etc.
References:
http://developer.android.com/guide/topics/ui/menus.html

Which of the following is a call-back method that inflates an options menu from file res/menu/menu.xml?

  • A. onOptionsItemSelected
  • B. onCreate
  • C. onCreateMenu
  • D. onCreateOptionsMenu


Answer : D

To specify the options menu for an activity, override onCreateOptionsMenu() (fragments provide their own onCreateOptionsMenu() callback). In this method, you can inflate your menu resource (defined in XML) into the Menu provided in the callback. For example:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.game_menu, menu);
return true;
}
References:
http://developer.android.com/guide/topics/ui/menus.html

Which of the following Activity methods is invoked when the user clicks on an options menu item?

  • A. onItemClicked
  • B. onItemSelected
  • C. onOptionsItemClicked
  • D. onOptionsItemSelected


Answer : D

When the user selects an item from the options menu (including action items in the app bar), the system calls your activity's onOptionsItemSelected() method.
References:
http://developer.android.com/guide/topics/ui/menus.html

Which of the following WebView methods allows you to manually load custom HTML markup?

  • A. loadData
  • B. loadHTML
  • C. loadCustomData
  • D. loadCustomHTML


Answer : A

Example: To load the desired web page from an HTML string:
String summary = "<html><body>You scored <b>192</b> points.</body></html>"; webview.loadData(summary, "text/html", null);
References:
http://developer.android.com/reference/android/webkit/WebView.html

Which of the following is the base class of all UI components?

  • A. ListView
  • B. Layout
  • C. View
  • D. ViewGroup


Answer : C

View is the base class for android.widget subclasses, which instantiate fully-implemented UI objects.
References:
http://eagle.phys.utk.edu/guidry/android/androidUserInterface.html

Which of the following is true about object arrayAdapter declared in the code below?
String[] items = {"Item 1","Item 2","Item 3"};
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items); listView.setAdapter(arrayAdapter);

  • A. It creates a TextView for each String in array items.
  • B. It creates Buttons for each String in array items.
  • C. It creates four views for listView.
  • D. It replaces the layout of the activity with three consecutive TextView items.


Answer : A

Which of the following is NOT a correct constructer for ArrayAdapter?

  • A. ArrayAdapter(Context context)
  • B. ArrayAdapter (Context context, int recourse)
  • C. ArayAdpater (Context context , int resource, int textViewResourceId)
  • D. ArrayAdapter (Context context , int resource, List<T> items)


Answer : A

Public ArrayAdapter Constructors include:
public ArrayAdapter (Context context, int resource)
public ArrayAdapter (Context context, int resource, int textViewResourceId) public ArrayAdapter (Context context, int resource, List<T> objects)
References:
http://developer.android.com/reference/android/widget/ArrayAdapter.html

Which of the following add a click listener to items in a listView?

  • A. onClickListener.
  • B. onItemClickListener.
  • C. onItemClicked.
  • D. onListItemClickListener.


Answer : B

AdapterView.OnItemClickListener is an interface definition for a callback to be invoked when an item in this AdapterView has been clicked.
References:
http://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener.html

Which of the following makes a ListView Clickable?

  • A. setClickable(true)
  • B. setVisibility(View.Visible)
  • C. setEnabled(true)
  • D. setItemsEnabled(true)


Answer : C

Which of the following classes is used by Intent to transfer data between different android components?

  • A. Extras
  • B. Bundle
  • C. Parcelables
  • D. PendingIntent


Answer : B

Bundle is generally used for passing data between various activities of android. It depends on you what type of values you want to pass, but bundle can hold all types of values, and pass to the new activity.
References:
http://stackoverflow.com/questions/4999991/what-is-a-bundle-in-an-android-application

Which of the following is true about implicit intents? (Choose two)

  • A. They do not have a component specified
  • B. They have components specified to run an exact class.
  • C. They must include information that allows Android system to choose the best component to run.
  • D. They must contain extra information saved in a Bundle object.


Answer : AC

Implicit intents do not name a specific component, but instead declare a general action to perform, which allows a component from another app to handle it.
References:
http://developer.android.com/guide/components/intents-filters.html

Which of the following classes should be extended to create a custom view?

  • A. View
  • B. ViewGroup
  • C. Context
  • D. Activity


Answer : A

All of the view classes defined in the Android framework extend View. Your custom view can also extend View directly, or you can save time by extending one of the existing view subclasses, such as Button.
References:
http://developer.android.com/training/custom-views/create-view.html

An AsyncTask can be cancelled anytime from any thread.

  • A. True
  • B. False


Answer : A

A task can be cancelled at any time by invoking cancel(boolean).
References:
http://developer.android.com/reference/android/os/AsyncTask.html

Which of the following is NOT true about onMeasure() method of class View?

  • A. It measures the view and its contents to determine the measured width and height.
  • B. It is invoked by measure().
  • C. When overriding this method, a developer must call setMeasuredDimension().
  • D. It takes three parameters: the height, width, and the depth of the view.


Answer : D

Syntax: protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec) onMeasure() measures the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.
References:
http://developer.android.com/reference/android/view/View.html#onMeasure(int, int)

Page:    1 / 16   
Exam contains 228 questions

Talk to us!


Have any questions or issues ? Please dont hesitate to contact us

Certlibrary.com is owned by MBS Tech Limited: Room 1905 Nam Wo Hong Building, 148 Wing Lok Street, Sheung Wan, Hong Kong. Company registration number: 2310926
Certlibrary doesn't offer Real Microsoft Exam Questions. Certlibrary Materials do not contain actual questions and answers from Cisco's Certification Exams.
CFA Institute does not endorse, promote or warrant the accuracy or quality of Certlibrary. CFA® and Chartered Financial Analyst® are registered trademarks owned by CFA Institute.
Terms & Conditions | Privacy Policy