CHAPTER 3 ANSWERS

1. The dp unit is density independent and 160dp is equivalent to one inch. The px unit corresponds to an actual pixel on screen. You should always use the dp unit because it enables your activity to scale properly when run on devices of varying screen size.

2. With the advent of devices with different screen sizes, using the AbsoluteLayout makes it difficult for your application to have a consistent look and feel across devices.

3. For radio buttons, you need to use the setOnCheckedChangeListener() method on the RadioGroup to register a callback to be invoked when the checked RadioButton changes in this group. When a RadioButton is selected, the onCheckedChanged() method is fired. Within it, you locate individual RadioButton and then call their isChecked() method to determine which RadioButton is selected.

4. The three specialized fragments are ListFragment, DialogFragment, and PreferenceFragment.

Get Beginning Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.