Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications
by James Talbot, Justin McLean, Jorge Hernandez
Summary
It’s important to refactor and keep your code clean, as you’ve learned in this chapter. Android gives you a way to lay out child views in relation to each other and to their parent view group, and adding event handlers to your code lets your app react to button clicks.
Looking further into the activity lifecycle identifies a few issues with the application you’re building. To fix these issues, you implement simple threading by using the Runnable interface and the Handler class. (Remember it’s important to not hold up the main thread of the UI, or you’ll get the dreaded Application Not Responding dialog box.) You can display a new activity by creating an intent and calling startActivity.
To store your application’s state, you can create ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access