Pin
Pin

Reputation: 4016

How to know what android:id Android expects?

In some android classes you can set a custom layout. As far as my understanding goes, these custom layouts need certain android:ids to work.

For example, for the ListActivity a ListView with @android:id/list has to be provided and this is specified in the documentation.

What about other views? For example, I was checking the API Demos and came across

<CheckBoxPreference
                android:key="child_checkbox_preference"
                android:dependency="parent_checkbox_preference"
                android:layout="?android:attr/preferenceLayoutChild"
                android:title="@string/title_child_preference"
                android:summary="@string/summary_child_preference" />

There's a layout specified for the preference. That layout seems to be preference_child.xml, in which there's @+android:id/title and @+android:id/summary, which I assume the view will use to provide the title and the summary, but is this documented anywhere?

How do I know what resource IDs I have to use so that everything automagically works?

Upvotes: 2

Views: 237

Answers (1)

Sean
Sean

Reputation: 5256

AFAIK, there's no trick to find out but to know the documentation or open the android's id.xml and look for references.

P.S. Your code demonstrates how to use a specific attribute out of an entire style (the use of "?"), it has nothing to do with ID's

Upvotes: 1

Related Questions