Книга: Beginning Android

What’s with the @ Signs?

What’s with the @ Signs?

Many widgets and containers only need to appear in the XML layout file and do not need to be referenced in your Java code. For example, a static label (TextView) frequently only needs to be in the layout file to indicate where it should appear. These sorts of elements in the XML file do not need to have the android:id attribute to give them a name.

Anything you do want to use in your Java source, though, needs an android:id.

The convention is to use @+id/... as the id value, where the ... represents your locally-unique name for the widget in question. In the XML layout example in the preceding section, @+id/button is the identifier for the Button widget.

Android provides a few special android:id values, of the form @android:id/.... We will see some of these in various chapters of this book, such as Chapters 8 and 10.

Оглавление книги


Генерация: 1.052. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз