Question

Just start developing with android and think instead of reading a book a webinar could be better because a webinar could also teach me short ways and how an android developer thinks when writing the code but now got a problem

<CheckedTextView
android:id="@android:id/text1"
android:checkMark="?android:attr/listChoiseIndicatorMultiple"
</>

I dont understand the above code up to now see lots of different id definitions some of them was for resources and start with @resource/name, and some of those id definitions was like @+id/name just for creating a new id for the component but this time it is using android:id/text1 and I dont understand why it is using it in that manner

Besides, the checkMark thing make me confuse more what are all those ?android:attr/listChoiseIndicatorMultiple means?

Could you please explain me and show me some resource where can I find all those magic attributes so I can cope next time by myself and hope someday can answer other newbie questions

Thanks a lot in advance, and all comment will be appreciated.

Was it helpful?

Solution

Well, reading the docs has always been helpful to me:

Android Developer Site

XML Layout specific docs

@android:id/text1 is just a format used when the id has been previously defined. When you put a + in there that means the framework should create the resource id if it doesn't already exist.

It's normal to use @+id/thisid when defining a new view in a layout, and then use @id/thisid to reference the aforementioned view from another part of the layout (say, in a RelativeLayout where you need to tell one widget to be below another).

A question mark before the ID indicates that you want to access a style attribute that's defined in a style theme, rather than hard-coding the attribute.

OTHER TIPS

@android:id/text1 basically this is used when you create any android component like button, layout, textviews etc.

but when you need any external component which is general for different platform like any color, image etc then you can declare it as @resource/name.

actually there is nothing different just keep one thing in mind that in @android:id/text1, id will simply work as an class name will contains other objects like textview, imageview or any other.

now if you declare @resource/name then in that also instead of id class name will be resource. actually when you will use it in java then these(@android:id/text1) will be converted into object hierarchy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top