Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Hands-On Android UI Development

You're reading from  Hands-On Android UI Development

Product type Book
Published in Nov 2017
Publisher Packt
ISBN-13 9781788475051
Pages 348 pages
Edition 1st Edition
Languages
Author (1):
Jason Morris Jason Morris
Profile icon Jason Morris

Table of Contents (21) Chapters

Title Page
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface
Creating Android Layouts Designing Form Screens Taking Actions Composing User Interfaces Binding Data to Widgets Storing and Retrieving Data Creating Overview Screens Designing Material Layouts Navigating Effectively Making Overviews Even Better Polishing Your Design Customizing Widgets and Layouts Activity Lifecycle
Test Your Knowledge Answers

Chapter 14. Test Your Knowledge Answers

This appendix contains answers to all the Test Your Knowledge quizzes that appear in the chapters.

Chapter 2 - Designing Form Screens


  1. When designing a form screen, what is the first thing you should consider?
    • The data you need from your user - this will determine what fields are required and will inform your other decisions
  2. What is the standard spacing increment in Material design?
    • 8 Density Independent Pixels
  3. The ConstraintLayout, ViewPager, and CardView are part of the support APIs. What does this mean?
    • Their bytecode must be included with your application if you use them
  4. When building a new layout, your root widget should always be which of these?
    • The simplest widget that makes sense for your layout - other options may provide more power, but will consume more system resources

Chapter 3 - Taking Actions


  1. What's the best way to implement event handlers?
    • There isn't one - you need to consider each case, and choose the most appropriate pattern
  2. What are the conditions for any methods that changes the state of a user-interface widget?
    • They must be called from the main thread
  3. Code running as part of an event handler should fulfill which of the following conditions?
    • Only interact with the user interface - anything else should be done on a worker thread
  4. When requesting data from another Activity, the data is returned through which of these?
    • A callback on your Activity object

Chapter 4 - Composing User Interface


  1. When developing a layout subclass, which of the following options is the best?
    • Avoiding assigning ID attributes to child widgets - the ID attributes can cause unexpected side-effects in the application
  2. Which of these applies to the Bundle passed at an Activity in onCreate?
    • It is populated in the onSaveInstanceState method
  3. When the data for an Adapter changes, which of the mentioned happens?
    • It should notify any attached listeners
  4. Fragments and View classes should meet which of the following conditions?
    • They should have their data and state pushed into them from the Activity

Chapter 5 - Binding Data to Widgets


  1. Android's data binding framework follows what sort of binding?
    • Model-View (unidirectional) binding
  2. Data Bound Layouts have variables that must be which of the following?
    • Any Java Object
  3. Which of the following features belongs to data binding expressions?
    • They are a special expression language
  4. To trigger an update of a data-bound user interface, you must do which of these?
    • Make a change that the Binding object can observe

Chapter 6 - Storing and Retrieving Data


  1. The Room API for Android provides which of the following?
    • A lightweight API on top of SQLite
  2. Returning LiveData from a Room DAO requires that you do which of these?
    • You observe it for changes in order to retrieve data
  3. Database queries that don't return LiveData should do what?
    • Be run on a worker thread
  4. Writing an update method for Room requires which of the listed?
    • An @Update method taking an Entity object on an interface

Chapter 7 - Creating Overview Screens


  1. An instance of RecyclerView will create one View instance for which of these?
    • Every item of data visible on the screen
  2. When attaching an observer to LiveData, you need to do which of the following?
    • Provide a valid LifecycleOwner
  1. Overview/Dashboard screens should have which of these features?
    • They should display an overview with the most important information first
  2. The ViewHolder class is used by the RecyclerView to do what?
    • Improve the data binding performance
  3. When using LiveData objects to reference data used by multiple Fragment objects, which of these is true?
    • The Fragment instances must share the same LiveData reference to see changes

Chapter 8 - Designing Material Layouts


  1. Elevation should be used for which of the following?
    • To selectively highlight one item above a flat layout
  2. CoordinatorLayout can be used to coordinate movement and size between which of these?
    • Any of its direct child widgets
  3. To change elevation of a widget in a backward-compatible way, you need to do which of the mentioned?
    • Use the ViewCompat class
  4. The GridLayout class should be used in which of the following conditions?
    • To lay out screens along grid lines

Chapter 9 - Navigating Effectively


  1. When using bottom tabs for navigation, which of these is important?
    • The tabs are of roughly equal importance
  2. Top tabs are preferred to bottom tabs in which of these situations?
    • When the user won't need to navigate as frequently
  3. Fragments can be used for navigation in which of these cases?
    • Any time the user navigates within the application
  4. When the user selects an item in a navigation drawer, which of these is true?
    • The drawer should be closed programmatically

Chapter 10 - Making Overviews Even Better


  1. How many different view types can you use in a single RecyclerView instance?
    • Any number
  2. When using a DiffUtil, which of the following applies to the data you are comparing?
    • It is exposed through a Callback
  3. When adding dividers to a RecyclerView, you should do which of these?
    • Make them distinct items in the dataset

Chapter 11 - Polishing Your Design


  1. When choosing a color scheme, it's important that the accent color has which of these features?
    • It is complementary to the primary color
  2. Dynamically generating a palette should meet which of these conditions?
    • It should be done on a background thread
  3. Which of these is to be kept in mind while animating layouts in your application?
    • They should not block or distract the user from achieving their goals
  4. Custom styles can be used to define which of these?
    • Default values for any attribute in a layout resource file

Chapter 12 - Customizing Widgets and Layouts


  1. When rendering specialized graphics for a custom widget, you need to do which of these?
    • Override the onDraw method
  2. Where should you create instances of graphics primitives such as Drawable, Paint, and Path for rendering in onDraw?
    • Anywhere that doesn't affect onDrawdirectly
  1. What are the two phases involved in the layout process?
    • Measurement and then layout
  2. When painting a Drawable object, you need to do which of the following?
    • Pass it a valid Canvas object
  3. To tell the platform that a widget needs to repaint itself (from the main thread), you use which of these?
    • View.invalidate()

 

lock icon The rest of the chapter is locked
arrow left Previous Chapter
You have been reading a chapter from
Hands-On Android UI Development
Published in: Nov 2017 Publisher: Packt ISBN-13: 9781788475051
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime}