Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
258 views
in Technique[技术] by (71.8m points)

android - How to fix <include> tag's & id‘s error when i use sourceSets- res.srcDirs to sort out layout xml files?

I trying to sort out src/main/res/layout xml files to make layouts files clear display function module, I created some functions folder in the res/layout folder, and move corresponding XML files in this folders. And i use following code in the build.gradle(:app):

android {
//other codes
sourceSets {
    main {
        res.srcDirs =
          [
            'src/main/res/layout/exampleFunction1',
            'src/main/res/layout/exampleFunction2/exampleFunction4',
            'src/main/res/layout/exampleFunction3',
            'src/main/res/layout',
            'src/main/res'
          ]
    }
}

But in the activity_main.xml,the xml layout was error, because i just use tags:

<include layout="@layout/main_examplexml_name  <!--ERROR-->
         android:layout_height="match_parent"
         android:layout_width="match_parent" />

Xml Include Tags Error Pic

At time,in MainActivity.java,init()funcation:findviewByID is error too.

In developer documents like no description in this demand,just this course: Re-using Layouts with

Reference

【Android Studio】分类整理res/Layouts中的布局文件(创建子目录)

question from:https://stackoverflow.com/questions/66058735/how-to-fix-include-tags-id-s-error-when-i-use-sourcesets-res-srcdirs-to-so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...