Chapter 9

Employing Basic Widgets

Every GUI toolkit has some basic widgets: fields, labels, buttons, and so forth. Android's toolkit is no different in scope, and the basic widgets provide a good introduction to how widgets work in Android activities.

Assigning Labels

The simplest widgets the label, referred to in Android as a TextView. As in most GUI toolkits, labels are bits of text that can't be edited directly by users. Typically, labels are used to identify adjacent widgets (e.g., a “Name:” label next to a field where the user fills in a name

In Java, you can create a label by creating a TextView instance. More commonly, though, you will create labels in XML layout files by adding a TextView element to the layout, with an android:text ...

Get Beginning Android 4 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.