How does ${packageName}.${activityClass} work in layout XML files?
Asked Answered
E

3

6

ADT now generates XML layouts with the following attributes:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${packageName}.${activityClass}" >

How do the design tools know which class it belongs to?

Enquire answered 5/6, 2014 at 12:4 Comment(0)
G
1

My Eclipse ADT autogenerates the following:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${relativePackage}.${activityClass}" >

</RelativeLayout>

My question is: "Is there an Eclipse ADT reference that lists and explains all of the available variables one can use with the Android Tools Attributes?"

For example, it would be nice to see something like:

  • relativePackage: resolves to the value of the package= attribute of the <manifest> element in the file "AndroidManifest.xml".
  • activityClass: resolves to the value of the android:name= attribute of the <activity> element in the file "AndroidManifest.xml".
  • etc. ...
  • ... with a list of any/all other variables available for use

I found some links related to the tools namespace, but none of them explain how Eclipse ADT resolves, for example, ${relativePackage}.

Android Tools Project Site

Tools Attributes -> shows the attributes available in the "tools" namespace

Designtime Layout Attributes -> shows some of the "how and why" you would use the attributes

StackOverflow Site

Android “tools” namespace in layout xml documentation -> shows abstraction of the attributes values into xml files

What's “tools:context” in Android layout files? -> shows a lot of good info on Tools Attributes, but gives no answer to my question "Is there an Eclipse ADT reference that lists ..."; it only shows tools:context=".MainActivity"

What's tools:layout in fragment xml file? -> gives a bit of insight into using Eclipse ADT Graphical Layout editor

Greta answered 25/10, 2014 at 22:14 Comment(0)
B
0

I don't know whether I got your question right but as far as I understood...it is about how does the ADT tool know that which package and which class...

The answer is at the time of creating the project, you might have mentioned (in general everybody does the same in most of the cases) the package name as well as the main activity class and from there the ADT tool picks up the details and puts them in the XML you referred...

Brahman answered 5/6, 2014 at 12:42 Comment(1)
No I mean it literally says ${activityClass} in the XML.Enquire
C
0
tools:context="${relativePackage}.${activityClass}"

realtivePackage and activityclass in there tags comes error how to solve

Capture answered 10/4, 2020 at 15:12 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.