Joseph Malicke Joseph Malicke - 1 year ago 86
Android Question

What is the "built in TextView widget android:text1" and the "ListView widget android:id/list"?

An Android tutorial guide uses the following XML definitions and quotes:

<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android=""

This XML uses the built-in Android ListView widget android:id/list.

<TextView xmlns:android=""
android:clickable="true />

This XML uses the built-in Android TextView widget android:text1.

First of all, I am used to seeing
properties defined like this:


What does it mean to use

Second, what does
built-in ... widget
mean in this context?

Answer Source

These are ids defined in the Android SDK and which are used in some of the layout XML files provided by the Android SDK. You can refer directly to those ids in XML (e.g. android:id="@android:id/text1") or in Java (e.g. findViewById( -- notice the fully-qualified name in java.

Some of these ids have special meaning in certain contexts. For example, if you are extending ListActivity or ListFragment, you must use android:id="@android:id/list" because those classes look for a ListView with that specific ID as part of their implementation. (If you don't provide a layout at all, those classes default to a layout with just a ListView in it.)

Note that you can still use these IDs outside of these special cases -- there's nothing preventing you from giving any view android:id="@android:id/list".

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download