forum

Home / DeveloperSection / Forums / What's “tools:context” in Android layout files?

What's “tools:context” in Android layout files?

Royce Roy 3510 11-Jun-2015
Starting with a recent new version of ADT, I've noticed this new attribute on the layout XML files, for example:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    tools:context=".MainActivity" />
What is "tools:context" used for?

How does it even know the exact path to the activity that is written there? Does it look at the package of the app, inside the manifest?

Is it limited to classes that extend Context or only activities? Is it usable for ListView items etc.?

Updated on 11-Jun-2015

Can you answer this question?


Answer

1 Answers

Liked By