O'Reilly logo

Beginning Android 2 by Mark L. Murphy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5

Employing Basic Widgets

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

Assigning Labels

The simplest widget is the label, referred to in Android as a TextView. As in most GUI toolkits, labels are bits of text that cannot be edited directly by users. Typically, they are used to identify adjacent widgets (e.g., a “Name:” label next to a field where you fill 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 property ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required