【发布时间】:2014-04-27 21:25:48
【问题描述】:
我使用 Android Studio 启动选项构建了我的项目(使用选项卡自动构建 action bar),因此为我生成了一点。然而,我确实为每个使用自定义adapters 的选项卡实现了list-view fragment。
我在从Chris Bane 添加下拉刷新库时遇到问题。也许我导入错了?我在 android 开发方面还很陌生,尤其是在这个新的 Gradle 方面。
我在这里在 build.gradle 文件中导入 github 存储库:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
}
所有减去 minSDKVersion 和依赖项的最后编译都是在我的项目创建时预先生成的。这个 build.gradle 文件是我的 `/app 文件夹中的那个。
Gradle 将正确同步,我将在项目根目录的 .idea 文件夹中看到来自操作栏 git 的文件。
这就是我感到困惑的地方:
在 github 存储库“快速启动”中它说
您需要做的第一件事是将可刷新视图包装在 PullToRefreshLayout 中:
通过代码示例执行如下操作:
<uk.co.senab.actionbarpulltorefresh.extras.actionbarcompat.PullToRefreshLayout>
<listview/>
</uk.co.senab.actionbarpulltorefresh.extras.actionbarcompat.PullToRefreshLayout>
uk.co.senab.actionbarpulltorefresh.extras 假设是我的项目名称,所以com.lucaapp.app?
这是我的 ListFragment 的 XML,您会在其中看到我的困惑:
<?xml version="1.0" encoding="utf-8"?>
<com.lucaapp.app.PullToRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ptr_layout" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#b5b5b5"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector" />
<TextView
android:id="@android:id/empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No Events" />
</com.lucaapp.app.PullToRefreshLayout>
在我尝试在我的片段类中实现来自quick start guide 的代码之前,这不会立即给我任何错误。我在尝试导入该 github 存储库方法时收到 Cannot Resolve Symbol 错误。
我已经尝试了以下方法,导致导入为红色并出现cannot resolve symbol 错误:
import com.lucapp.app.PullToRefreshAttacher;
import com.lucapp.app.PullToRefreshLayout;
import uk.co.senab.actionbarpulltorefresh.extras.actionbarcompat.PullToRefreshAttacher;
【问题讨论】:
-
为什么在使用 minsdk=14 时使用 compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'?使用:编译'com.github.chrisbanes.actionbarpulltorefresh:library:+'
标签: android listview android-fragments android-listfragment pull-to-refresh