1

I already search the article and search question on this forum both only showing "how to setting gradle sub directory"

I already set the build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        applicationId "com.ardyfeb.kolabs"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
          res.srcDirs = [
               'src/main/res/layout/partials',
               'src/main/res/layout',
               'src/main/res'
          ]
        }
    }
}

dependencies {
    compile 'com.android.support:recyclerview-v7:+'
    compile 'com.android.support:multidex:+'
    compile 'com.android.support:cardview-v7:+'
    compile 'com.android.support:design:+'
    compile 'com.android.support:support-v13:+'
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.android.support:support-v4:+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

My directory tree

src/main/res
      -- layout
           -  main.xml
           -- partials
               - header.xml

My question is : How to include the partials/header.xml ? With tag

Example :

<include
        layout="@layout/toolbar"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:id="@+id/header"/>
Ardy Febriansyah
  • 650
  • 1
  • 6
  • 14

1 Answers1

1
<include
        android:id="@+id/tagOne"
        layout="@layout/header"
        ...
        />

and

<include
        android:id="@+id/tagTwo"
        layout="@layout/header"
        ...
        />

Example

If you have TextView then you can find views by tag like

TextView headerOneText = findViewById(R.id.tagOne).findViewById(R.id.textView);

And

TextView headerTwoText = findViewById(R.id.tagTwo).findViewById(R.id.textView);
Khemraj Sharma
  • 57,232
  • 27
  • 203
  • 212