由Chris Banes实现ActionBar-PulltoRefresh,库错误等 [英] Implementing ActionBar-PulltoRefresh by Chris Banes, library errors etc

查看:140
本文介绍了由Chris Banes实现ActionBar-PulltoRefresh,库错误等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



通过pull导入Android Listview刷新,属性错误



根据Google目前使用的Chris Banes的ActionBar-PullToRefresh: https://github.com/chrisbanes/ActionBar-PullToRefresh
我已经决定我也想使用该图书馆的Android应用程序,我目前正在为实习而发展。当我尝试从已解压缩的zip文件中将现有代码导入到工作空间中时,我立即在图书馆和示例活动中收到大量错误。例如,在库文件夹中,在ActionBarPullToRefresh.java中,它强调了第一个私有的hashmap中的Class,并且对泛型类型的引用应该参数化。



IDE (eclipse)也给其他文件夹带来了大量错误,当我将库文件夹添加到我的主项目库中时,使用属性 - > android选项卡,将错误传递到该项目(逻辑上)。



有没有人可以向我发送方向,如何成功导入和使用这个图书馆?

解决方案

我将在这里写下来为将来的PullToRefresh用户。我使用 IntelliJ IDEA 而不是eclipse,请记住,模块项目相当。当您必须向Eclipse添加项目时,操作是在IDEA中添加模块。



ActionBarSherlock (现在的ABS)的示例。 p>

你有什么


  1. 你有一个 Module 命名为MyProject。这是您的主要Android模块。

  2. 您要将PullToRefresh添加到MyProject中的几个Fragments(例如)。

第一步:下载并复制。



我个人喜欢有一个克隆或分支的库我'用来读取提交和更改日志。不仅可以通过查看其他人的代码来学习,还可以获得有关您使用的库的最新消息。这是一个双赢的局面。记住Jeff Atwood说:阅读来源,卢克。所以为了做到这一点,克隆ActionBar-PullToRefresh从正确的URL 。 p>

现在我不喜欢克隆我的模块/项目,所以我通常克隆项目在别的地方,然后手动移动我需要的。这很乏味,但是我只能得到我想要的东西。那么你需要什么呢?该克隆包含两个重要的目录:其他。我们将需要这些东西。



将库目录复制到您的项目根目录中: / path / to / your / project / pulltorefresh
将相应的(ABS或兼容)额外的副本复制到您的项目根目录中。



这是您到目前为止所得到的:

  / path / to / your / project / MyProject 
/ path / to / your / project / pulltorefresh
/ path / to / your / project / pulltorefresh-abs(或compat)

第二步导入这些:
将这些模块(eclipse中的项目)导入项目/工作区。如果您知道您的IDE,但是作为一个快速参考,这应该很简单:文件 - >导入模块 - >从上面找到pulltorefresh文件夹(稍后再使用-ab或compat),然后按照向导进行操作。如果您使用Eclipse,请查看此链接以了解如何执行



现在您应该在左面板(⌘1)中有以下结构

  MyProject 
pulltorefresh
pulltorefresh-abs

步骤3 添加正确的引用



假设 MyProject actiobnarsherlock.jar (因为你需要它)或相应的android支持库 compat ,你有相应的 android-support-v13 (或v4)以及...


  1. pulltorefresh 不需要任何库参考。

  2. pulltorefresh-abs 需要引用: pulltorefresh android-suppport -vX actiobbarsherlock

  3. MyProject 需要引用: pulltorefresh-abs android-suport-vX actiobbarsherlock li>

当然,android支持和actiobarsherlock都可以坐在MyProject中,并由其他库导出(从那里获取),但这是项目管理101;)



步骤4 集成!
这更简单,只需遵循
快速入门指南
记住:在旧版本的lib中,您已经在活动中拥有一名参与者,这不再需要。阅读文档,它非常简单(这样更灵活)。



等等,如果不使用Sherlock或兼容? / strong>



我还没有这样做,但我的猜测是:


  1. 不要在 extras 中导入-abs或-compat。只需导入 pulltorefresh

  2. 从您的项目中,引用 pulltorefresh

坚持...进口怎么办?



获得正确的导入对于任何图书馆都很重要,您必须注意并不要盲目让您的IDE为您(或至少总是仔细检查您要导入的内容)。您会惊讶地发现有多少名称碰撞在那里。



对于Action Bar Sherlock基于项目,导入应该是:

  import uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.PullToRefreshLayout; 
import uk.co.senab.actionbarpulltorefresh.library.ActionBarPullToRefresh;
import uk.co.senab.actionbarpulltorefresh.library.listeners.OnRefreshListener;

对于非sherlock 纯项目:

  import uk.co.senab.actionbarpulltorefresh.library.ActionBarPullToRefresh; 
import uk.co.senab.actionbarpulltorefresh.library.listeners.OnRefreshListener;
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout;

你在哪里得到这些?!?!?!?! / p>

查看样本,Luke。



例如,这是股票版本



最后一步将是获利...但是我离开了你;)



如果你还有问题,那些家伙很友善,问懒惰的问题。请随时关注该项目并参与 github的问题页面



祝你好运!


Following up on my previous question about importing a certain library from github in my project, I decided I wanted to implement a different one, but I get lots of errors at this point.

Importing Android Listview refresh by pull, project-properties error

In line with Google currently using Chris Banes' ActionBar-PullToRefresh: https://github.com/chrisbanes/ActionBar-PullToRefresh, I've decided I wanted to used that library as well for the Android app that I'm currently developing for my internship. When I try to import the existing code into the workspace from the unpacked zip-file though, I instantly get a ton of errors, in the library as well as in the example activities. For instance, in the library folder, in ActionBarPullToRefresh.java, it underlines Class within the first private hashmap and says references to the generic type Class should be parameterized.

The IDE (eclipse) also gives tons of errors to the other folders included, and when I add the library folder to the libraries of my main project, using the properties -> android tab, it carries over the errors to that project (quite logically).

Could anyone send me into a direction as to how I should successfully import and use this library?

解决方案

I will write this here for future PullToRefresh users. I use IntelliJ IDEA instead of eclipse, so remember that the word Module and Project are equivalent. When you have to add a project to Eclipse, the action is add module in IDEA.

Example with ActionBarSherlock (ABS from now).

What you have:

  1. You have a Module named: MyProject. This is your main Android module.
  2. You want to add PullToRefresh to a few Fragments (for example) in your MyProject.

Step One: Download and Copy.

I personally like to have a clone or fork of the libraries I'm using to read the commits and change logs. Not only you learn by seeing other people's code, but also you get the "latest news" about the libraries you use. It's a win-win situation. Remember what Jeff Atwood said: "Read The Source, Luke". So in order to do this, Clone ActionBar-PullToRefresh from the right URL.

Now I don't like having the clone with my modules/projects so I usually clone projects somewhere else and later manually move what I need. It's tedious but that way I only get what I want. So what do you need then? The clone contains two important directories: Extras and Library. We're going to need stuff from these.

Copy the library directory to your project root: /path/to/your/project/pulltorefresh Copy the corresponding (ABS or Compat) extra to your project root as well…

This is what you got so far:

/path/to/your/project/MyProject
/path/to/your/project/pulltorefresh
/path/to/your/project/pulltorefresh-abs (or compat)

Step Two Import these: Import these modules (projects in eclipse) into the project/workspace. This should be simple if you know your IDE, but as a quick reference: File -> Import Module -> find the pulltorefresh folder from above (and the -abs or compat later) and follow the wizard. If you're using Eclipse, check this link to know how to do it.

Now you should have in your left panel (⌘1) the following structure

MyProject
pulltorefresh
pulltorefresh-abs

Step 3 Add the right references

Assuming MyProject has actiobnarsherlock.jar (because you need it) or the corresponding android support library for compat and that you have the corresponding android-support-v13 (or v4) as well…

  1. pulltorefresh doesn't need any library reference.
  2. pulltorefresh-abs needs a reference to: pulltorefresh, android-suppport-vX and actiobbarsherlock
  3. MyProject needs a reference to: pulltorefresh-abs, android-suport-vX and actiobbarsherlock

Of course both android-support and actiobarsherlock could sit in MyProject and be exported (and taken from there) by the other libraries, but that's project management 101 ;)

Step 4 Integrate! This is easier, just follow the Quick Start Guide. REMEMBER: in older versions of the lib you had to have an attacher in an Activity, that is no longer necessary. Read the documentation, it's very simple (and much more flexible this way).

Wait, What If You Don't Use Either Sherlock or Compat??

I haven't done this yet, but my guess is:

  1. Don't import -abs or -compat in extras. Just import pulltorefresh.
  2. From your project, reference pulltorefresh.

Hold on… what about imports?!

Getting the right imports is important for any library, you have to pay attention and not blindly let your IDE do it for you (or at least always double check what you're importing). You'd be surprised to see how many "name collisions" are out there.

For Action Bar Sherlock based projects, the imports should be:

import uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.PullToRefreshLayout;
import uk.co.senab.actionbarpulltorefresh.library.ActionBarPullToRefresh;
import uk.co.senab.actionbarpulltorefresh.library.listeners.OnRefreshListener;

For a non sherlock pure project:

import uk.co.senab.actionbarpulltorefresh.library.ActionBarPullToRefresh;
import uk.co.senab.actionbarpulltorefresh.library.listeners.OnRefreshListener;
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout;

Where did you get those?!?!?!?!

By looking at the samples, Luke.

For example, here's for the stock version.

The final step would be to profit… but I leave that up to you ;)

If you still have an issue, the guys are friendly provided you don't ask lazy questions. Feel free to follow the project and participate in the issues page at github.

Good Luck refreshing!

这篇关于由Chris Banes实现ActionBar-PulltoRefresh,库错误等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆