Book Image

Android User Interface Development: Beginner's Guide

By : Jason Morris
Book Image

Android User Interface Development: Beginner's Guide

By: Jason Morris

Overview of this book

<p>There are over 30,000 applications for Android that have been downloaded over a million times already. What makes yours any different? Building a compelling user-interface that people understand and enjoy is vital for the survival of a new application in an environment where look and feel may be the only thing between a user purchasing your application; or deleting it forever.<br /><br />Working through examples, code-snippets, and screenshots this book introduces the fundamentals of good user-interface design from a developer's point of view. This book will put you above the rest by showing you how to build striking user interfaces to grasp your app users' attention enough to make them shell out some bucks to buy your application.</p> <p>The <em>Android User Interface Development Beginner's Guide</em> will tell you everything you need to know to style your applications from bottom up. Given the importance of user-interface design on a touch-screen device, this book aims to equip its reader with the knowledge required to build killer Android applications. Starting simply, and keeping things easy, this book will take you on a step-by-step journey to understanding the principals of good user-interface design, and how to implement the best user interfaces on an Android mobile device. It aims at building design understanding on a chapter-by-chapter basis, while introducing platform knowledge through examples.</p>
Table of Contents (18 chapters)
Android User Interface Development
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Time for action – creating the CursorAdapter


The CursorAdapter is much more complex to set up than the ArrayAdapter. For one thing, we offer more options with the CursorAdapter than we did with the ArrayAdapter. Our CursorAdapter can be made to display either one or two line list items, based on whether there are one or two columns specified. While the ArrayAdapter includes some default filtering logic, we need to provide a little more support for the CursorAdapter.

  1. To start with, we allow for two different column naming conventions to be used, along with some defaults. Declare a utility method to find the expected column names from the Intent:

    private String getColumnName(
            final Intent intent,
            String primary,
            String secondary,
            String def) {
  2. First, try and use the primary attribute name to get a column name:

    String col = intent.getStringExtra(primary);
  3. If the column name is null, try the secondary attribute name:

    if(col == null) {
        col = intent.getStringExtra...