我可以在文件夹树中列出所有字符串资源文件吗?

时间:2015-08-04 01:35:52

标签: android android-studio

我使用基于免费和专业版的productFlavors创建项目,并为不同的版本使用不同的字符串资源文件,文件夹构造是cc.png。

如果我在面板中更改Build Variant,Android选项卡中的值显示两个strings.xml(2),一个位于主文件夹,另一个位于free或pro文件夹,可以看到aa.png和bb.png。

我希望所有的字符串资源文件可以一起显示,它会显示三个string.xml(3),第一个是位于主文件夹,第二个是位于free文件夹,第三个是位于pro文件夹。我怎样才能做到这一点 ?谢谢!

CC.Png

enter image description here

AA.png

enter image description here

BB.png

enter image description here

的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "info.dodata.messagecleanup"
        minSdkVersion 9
        targetSdkVersion 22
        versionCode 7
        versionName "1.07"
        archivesBaseName = "MessageCleanup-V" + versionName
    }


    productFlavors {
        free {
            applicationId "info.dodata.messagecleanup"
            buildConfigField "String", "AppName", "\"Message Cleanup\""
        }


        pro {
            applicationId "info.dodata.messagecleanup.pro"
            buildConfigField "String", "AppName", "\"Message Cleanup Pro\""
        }
    }


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.google.android.gms:play-services:7.3.0'
}

2 个答案:

答案 0 :(得分:6)

不幸的是,Android项目窗格视图不支持此行为。 Android视图专门用于显示给定构建变体的项目状态,而不是所有变体。

正如您已经发现的,在所有可用配置中查看资源的最简单方法是使用"项目"而不是" Android"图。

您也可以自由提交功能请求on the Android issue tracker,以便显示所有变体中可用资源的选项。

答案 1 :(得分:3)

您可以在IntelliJ / Android Studio中定义显示特定文件夹/文件的自定义范围:

enter image description here

然后,您可以从范围下拉选择器中选择该自定义范围:

enter image description here

那就是说,我认为在字符串文件之间导航的更有效方法是点击“Search Everywhere”热键,输入“strings.xml”,然后选择你想要的那个:

enter image description here