无法从ActionBar-PullToRefresh库访问该类

时间:2014-08-27 16:29:32

标签: android android-studio pull-to-refresh android-actionbar-compat

我正在进行一个Android项目,我需要导入ActionBar-PullToRefresh库,所以我使用gradle导入库,如下所示:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile('com.android.support:appcompat-v7:20.0.0') {
        force = true
    }
    compile('com.android.support:support-v4:20.0.0') {
        force = true
    }
    repositories {
        mavenCentral()
    }
    compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
}

然后我Sync Project with Gradle Files,所以我可以在我的布局xml文件中使用PullToRefreshLayout。但是当我在Fragment代码中使用库的类时,我无法获得任何代码触发器。当我拼写整个班级名PullToRefreshLayout时,Android工作室将不会自动导入该班级。那是什么问题。

接下来的两个文件是根目录和我的app目录中的build.gradle文件:

根目录中的build.gradle文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

应用程序目录中的build.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.ifeve.ifeveforandroid"
        minSdkVersion 10
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}



dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile('com.android.support:appcompat-v7:20.0.0') {
        force = true
    }
    compile('com.android.support:support-v4:20.0.0') {
        force = true
    }
    repositories {
        mavenCentral()
    }
    compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
}

1 个答案:

答案 0 :(得分:0)

尝试以这种方式导入库,在此行中添加依赖关系部分:

compile 'com.github.chrisbanes.actionbarpulltorefresh:library:0.9.9'