在我现有的项目 (eclipse) 中导入 CardView 和 RecyclerView (Android 5.0)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26492345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:06:14  来源:igfitidea点击:

Importing CardView and RecyclerView (Android 5.0) in my existing project (eclipse)

androideclipseandroid-5.0-lollipopandroid-recyclerviewandroid-cardview

提问by Harsh Pokharna

I want to import CardView and RecyclerView in my existing project. I am using ECLIPSE. I read other answers in stackoverflow but all of them are for Android Studio. ve Can anyone please help me ?

我想在我现有的项目中导入 CardView 和 RecyclerView。我正在使用 ECLIPSE。我在 stackoverflow 中阅读了其他答案,但所有答案都适用于 Android Studio。ve 任何人都可以帮助我吗?

The error I am receiving is : CardView cannot be resolved to a type.

我收到的错误是: CardView 无法解析为类型。

Update: Commonwares answer helped me solve this. But now I have another error. (Error inflating class and android.support.v7.widget.CardView). Please someone help me.

更新:Commonwares 的回答帮助我解决了这个问题。但现在我有另一个错误。(错误膨胀类和 android.support.v7.widget.CardView)。请有人帮助我。

采纳答案by CommonsWare

They are also available as Android library projects now, in extras/android/support/v7/of your SDK installation. Make a copy of those projects elsewhere on your hard drive, import them into Eclipse, then reference them as libraries from your app following the instructions in the documentation.

它们现在也可以作为 Android 库项目在extras/android/support/v7/您的 SDK 安装中使用。在硬盘驱动器的其他位置复制这些项目,将它们导入 Eclipse,然后按照文档中的说明将它们作为应用程序中的库进行引用。

回答by j2emanue

Currently to get the recyclerView you first download from the sdk manager the Android support repository in the 'Extras" section. After that you need to import all the libraries from here (starting from your sdk folder path):

目前,要获取 recyclerView,您首先要从 sdk 管理器下载“Extras”部分中的 Android 支持存储库。之后,您需要从此处导入所有库(从您的 sdk 文件夹路径开始):

sdk\extras\android\m2repository\com\android\support

enter image description here

在此处输入图片说明

回答by Blue_Alien

adding android-support-v7-recyclerview.jarfrom the folder: sdk\extras\android\support\v7\recyclerview\libsto the libsresolved my problem.

android-support-v7-recyclerview.jar从文件夹添加:sdk\extras\android\support\v7\recyclerview\libs解决了我的问题。

回答by xiaoyee

Finally, i resolved my problem.

最后,我解决了我的问题。

.../sdk/extras/android/support/v7/

.../sdk/extras/android/support/v7/

>appcompat
    >libs
        >android-support-v4.jar
        >android-support-v7-appcompat.jar
>cardview
    >libs
        >android-support-v7-cardview.jar
>gridlayout
    >libs
        >android-support-v7-gridlayout.jar
>mediarouter
    >libs
        >android-support-v7-mediarouter.jar
>palette
    >libs
        >android-support-v7-palette.jar
>recyclerview
    >libs
        >android-support-v7-recyclerview.jar

copy all jar file above to your project libs, and use this android-support-v4.jar above instead of yours

将上面的所有 jar 文件复制到您的项目库中,并使用上面的 android-support-v4.jar 而不是您的

回答by user2779311

For RecyclerView i am able to run by simply adding the jar file of recycler obtained from the libs folder of recycler within v7 support folder for cardview , i imported it as a android project , made it as a library and added to my project. the UI in my android worked perfect for first run but now it shows error in the UI editor but runs perfectly in emulator. hope it helps

对于 RecyclerView,我只需在 cardview 的 v7 支持文件夹中添加从 recycler 的 libs 文件夹中获取的 recycler jar 文件即可运行,我将其作为 android 项目导入,将其作为库并添加到我的项目中。我的 android 中的 UI 非常适合第一次运行,但现在它在 UI 编辑器中显示错误,但在模拟器中完美运行。希望能帮助到你

回答by thaitujim

add appcompat-v7.jarto your libs. This problem will be resolved.

添加appcompat-v7.jar到您的库中。这个问题将得到解决。