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" />
什么是“工具:上下文”用于?
它怎么知道写在那里的活动的确切路径?它是否在清单中查看应用程序的包?
它仅限于扩展Context或仅扩展活动的类吗?它可用于ListView项目等吗?
解决方法:
这是工具UI编辑器用于呈现布局预览的活动.记录here:
This attribute declares which activity this layout is associated with by default. This enables features in the editor or layout preview that require knowledge of the activity, such as what the layout theme should be in the preview and where to insert onClick handlers when you make those from a quickfix
标签:android,xml,android-layout,android-context,android-tools-namespace 来源: https://codeday.me/bug/20190916/1807079.html