Книга: Beginning Android

Useful Methods

Useful Methods

You can toggle whether or not a widget is enabled via setEnabled() and see if it is enabled via isEnabled(). One common use pattern for this is to disable some widgets based on a CheckBox or RadioButton selection.

You can give a widget focus via requestFocus() and see if it is focused via isFocused(). You might use this in concert with disabling widgets as previously mentioned, to ensure the proper widget has the focus once your disabling operation is complete.

To help navigate the tree of widgets and containers that make up an activity’s overall view, you can use:

• getParent() to find the parent widget or container

• findViewById() to find a child widget with a certain ID

• getRootView() to get the root of the tree (e.g., what you provided to the activity via setContentView())

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

Оглавление статьи/книги

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