Android Interview Questions and Answers Set 6

51.What is needed to make a multiple choice list with a custom view for each row?

Multiple choice list can be viewed by making the CheckBox android:id value be “@android:id /text1″. That is the ID used by Android for the CheckedTextView in simple_list_item_multiple_choice.

52.How is nine-patch image different from a regular bitmap?

It is a resizable bitmap resource that can be used for backgrounds or other images on the device. The NinePatch class permits drawing a bitmap in nine sections. The four corners are unscaled; the four edges are scaled in one axis, and the middle is scaled in both axes.

53.what is Android User Interface ?

User interface is what the user will see and interact with to perform some operations. Android comes with many friendly UI elements and layouts which helps to build interactive applications.

54.What is User Events ?

Event is a user interacting with the help of a Touchscreen. The Android framework maintains an Event Queue in which the events are arranged as they occur. The events are removed in First-In-First-Out (FIFO) basis.

55.What is the use of WebView in android?

A WebView is an android UI component that displays webpages. It can either display a remote webpage or can also load static HTML data. This encompasses the functionality of a browser that can be integrated to application. WebView uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, etc

56.Why is emulator important in Android environment?

With emulator, it becomes easy for the developers to play around, edit and create the interface easily. Thus, it acts more like a mobile phone. With emulator it becomes easy to write and even perform the test codes and debug. It is the safest place that can be used for testing the codes

57.What are common use cases for using an Intent?

  • starting an internal Activity (explicit Intent)
  • starting an internal Service (explicit Intent)
  • starting an external Activity/Application (implicit Intent)
  • delivering a broadcast

 58.When to use AsyncTask?

AsyncTask is a convenient way to perform short operations (a few seconds) from within an Activity or Fragment.

When using an Asynctask inside an Activity or Fragment, check if a running AsyncTask is canceled when the user leaves the Activity/Fragment. Implement AsyncTask inside an Activity or Fragment always as a static inner class and avoid references to the outer Activity/Fragment to avoid memory leaks.

59.What is the main purpose of a Fragment?

The main purpose of a Fragment is to support a more dynamic UI (tablets, smartphones) and also to make the reuse of UI components a lot easier.

A Fragment can also exist without its own UI as an invisible worker for the Activity.

A Fragment is closely tied to the Activity it is in. When the Activity is paused, so are all fragments in it; When the Activity is destroyed, so are all fragments in it.

60.What is the ViewHolder-Pattern?

The ViewHolder design pattern can be used to increase the speed at which a ListView renders data.

The pattern avoids the repeated lookup of view resources. The number of times which the findViewById() method is invoked is drastically reduced, existing views do not have to be garbage collected and new views do not have to be inflated. The view references for every row are stored in a simple object for later reuse.