What is the meaning of this Android code?
What is the difference between *
,+
and empty:
@*android:id
like this in android_ics/packages/apps/Setting/res/layout
<TextView android:id="@*android:id/timeDisplayForeground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="none"
android:textSize="@dimen/crypt_clock_size"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/crypt_keeper_clock_foreground"
android:layout_alignLeft="@*android:id/timeDisplayBackground"
android:layout_alignTop="@*android:id/timeDisplayBackground"
android:layout_marginBottom="6dip" />
The * allows you to access private resources. Private resources are private for a reason as their name could change in the future as part of a firmware or skin update.
It's not a good idea to use these resources unless you're working in an environment where you know these resources won't change and break your app in the future.
In your example, the private resources are being referenced by a system app which is where you'll most commonly see this * referencing used.
I answered earlier but may have misunderstood your question. There is a generated file in your project called R.java which has your resources listed. For example, when you create your view and add buttons, you'll see some of that information going into your R.java file automatically. In Java, you access the information using these members. In XML however, you must access them by referencing the labels or nodes.
@android:id refers to the public system member called "id"
@id refers to one that you've created
@+id says to create one called "id" (and what to set it to)
@*android:id refers to a private system member
Refer to: http://developer.android.com/training/basics/firstapp/building-ui.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With