What two methods you have to override when implementing Android context menus?
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?
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?
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?
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?
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?
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);
Answer : A
Which of the following is NOT a correct constructer for ArrayAdapter?
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?
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?
Answer : C
Which of the following classes is used by Intent to transfer data between different android components?
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)
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?
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.
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?
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)
Have any questions or issues ? Please dont hesitate to contact us