Dha*_*val 4 android android-layout android-xml
最近我遇到了tools:context
在我的布局文件中使用活动的用例。我了解到我可以使用它来将 Activity 类文件关联到我的布局文件。
但是我如何使用它来将 Fragment 类文件与任何布局相关联呢?
Bacuase 正如我所尝试的那样,它仅在自动完成建议中显示活动列表。
你有没有尝试过这样做:
假设Relative layout
您的布局中是您的父布局fragment's
:
<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=".Folder.Fragment" >
Run Code Online (Sandbox Code Playgroud)
.Fragment class
现在这个 .xml 文件将与您的片段相关联。
归档时间: |
|
查看次数: |
2083 次 |
最近记录: |