相关疑难解决方法(0)

Android布局文件中的"工具:上下文"是什么?

从最新的ADT版本开始,我注意到布局XML文件上的这个新属性,例如:

<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" />
Run Code Online (Sandbox Code Playgroud)

什么是"工具:上下文"用于?

它怎么知道写在那里的活动的确切路径?它是否在清单中查看应用程序的包?

它仅限于扩展Context或仅扩展活动的类吗?它可用于ListView项目等吗?

xml android android-context android-layout android-tools-namespace

908
推荐指数
5
解决办法
23万
查看次数