Fir*_*mon 5 android android-layout android-xml android-tools-namespace
我读过有关tools:context 的内容,发现它在开发时非常有用,因为它可以帮助我了解我使用了当前 Xml 的哪些活动。
我的问题是:
我有 2 个活动,使用相同的 Xml 文件(重复使用相同的layout.xml
文件),但我无法使用tools:context
如何
tools:context
在 Xml 中使用链接 2 个活动?
我努力了:
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
tools:context="com.example.mytestapp.MainActivity,com.example.mytestapp.Main2Activity">
<!-- Other Layouts Here -->
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这给了我红线
还尝试使用:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:tools2="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="com.example.mytestapp.MainActivity"
tools2:context="com.example.mytestapp.Main2Activity">
<!-- Other Layouts Here -->
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这不会给出红线,但是当我运行它们时,我收到以下错误:
Error:(2) error: duplicate attribute.
Error:(2) duplicate attribute.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1981 次 |
最近记录: |