我使用 Android Studio 启动选项构建了我的项目(使用选项卡自动构建 action bar
),所以为我生成了一些。不过,我确实为每个使用自定义 适配器
的选项卡实现了一个 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 repo“快速启动”中它说
The first thing you need to do is wrap your refreshable view in a 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>
在我尝试在我的 fragment 类中实现快速入门指南
中的代码之前,这不会立即给我任何错误。我在尝试导入该 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;
最佳答案
现在 android 引入了新的简单功能,称为滑动刷新布局。请引用本站devloper site和一个 simple example
关于带有 ListView fragment 和自定义 ListView 适配器的 Android 下拉刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22543047/