내 프로젝트 (Eclipse)에서 android.support.v7.widget.CardView 사용
v7 지원 라이브러리의 새로운 개정판의 일부인 것처럼 보이는 새로운 Android L 개발자 미리보기 지원 라이브러리 ( 여기에서 언급했듯이 ) 와 함께 도입 된 새로운 CardView 위젯을 사용하고 싶습니다 .
이제 SDK 버전을 업데이트하고 최신 지원 라이브러리 패키지를 다운로드했지만 여전히 새 CardView 위젯을 찾을 수 없습니다.
이미 웹과 공식 문서를 검색했지만 새 지원 라이브러리를 얻을 수있는 위치에 대한 힌트를 얻지 못했습니다.
어떤 도움이라도 대단히 감사합니다!
편집 : ADT / Eclipse를 사용하고 있습니다.
Gradle 또는 Android Studio를 사용하여 com.android.support:cardview-v7
.
이 시간에 정규 안드로이드 라이브러리 프로젝트를 할 수없는 것 cardview-v7
, leanback-v17
, palette-v7
, 또는 recyclerview-v7
. Google이 그러한 도서관 프로젝트를 언제 / 언제 배송할지 모르겠습니다.
마침내 ADT / Eclipse에서 CardView를 사용하는 방법을 찾았습니다. 실제로는 매우 쉽습니다.
- Android Studio에서 새 프로젝트 만들기
- 이 질문에 대한 다른 답변에 설명 된대로 CardView 종속성을 추가하십시오.
- ADT를 열고 패키지 이름으로 새 라이브러리 프로젝트를 만듭니다.
android.support.v7.cardview
- 자동 생성 된 모든 리소스 ADT 삭제
exploded-aar
Android Studio 에서 폴더를 찾고 다음 파일을 다음 위치에 복사합니다.- res / values / values.xml 을 ADT 프로젝트의 동일한 위치에 추가합니다.
- ADT 프로젝트의 classes.jar 에서 libs /로
- AndroidManifest.xml은이를 사용하여 ADT에서 자동 생성 매니페스트를 대체합니다.
- 빌드 경로에 classes.jar을 추가하고 내보내 졌는지 확인하십시오.
- CardView를 사용하려는 프로젝트의 라이브러리 프로젝트에 대한 참조를 추가
Adding libraries with resources
하십시오. 여기에 제공된 단계를 따를 수 있습니다 . https://developer.android.com/tools/support-library/setup.html
AAR의 콘텐츠를 얻기 위해 새 Android Studio 프로젝트를 만들어야하는 대신 로컬 Maven 저장소에서 AAR을 찾아 압축을 풀 수도 있습니다. 아래의 Andrew Chen이 제공 한 단계를 따르십시오.
CardView 라이브러리는 여전히 미리보기 및 WIP 일 뿐이므로 소스 및 ADT 호환 형식으로 사용하지 못할 수 있습니다. 다음 릴리스에서 버그 수정 및 개선 사항이있을 수 있으므로 라이브러리를 최신 상태로 유지하는 것이 중요합니다. Gradle 종속성을 사용하기 쉽지만 위에 제공된 단계를 사용할 때 수동으로 수행해야합니다.
build.gradle에 다음을 추가해야합니다.
dependencies {
...
compile 'com.android.support:cardview-v7:+'
}
그리고 Sync Project with Gradle Files
. 마지막으로 여기에 설명 된대로 CardView를 사용할 수 있습니다 .
나는 다음을 수행했으며 eclipse 프로젝트에서 작동하지 않는 경우 다른 위젯에도 사용할 수있는 recyclerview 문제를 해결했습니다.
• sdk \ extras \ android \ m2repository \ com \ android \ support \ recyclerview-v7 \ 21.0.0-rc1 디렉토리로 이동합니다.
• recyclerview-v7-21.0.0-rc1.aar 파일을 복사 하고 이름을 .zip으로 바꿉니다.
• 파일의 압축을 풀면 classes.jar이 생성됩니다 (jar 파일의 이름을 더 의미있는 이름으로 변경).
• 프로젝트 빌드 경로 또는 lib 디렉토리에서 다음 jar를 사용합니다.
그리고 그것은 당신의 오류를 해결합니다.
행복한 코딩 :)
https://github.com/yongjhih/CardView
CardView v7 이클립스 프로젝트. (sdk / extras / android / m2repository / com / android / support / cardview-v7에서)
이 프로젝트는 단계적으로 구축되었습니다.
cp {sdk}/extras/android/m2repository/com/android/support/cardview-v7/21.0.0-rc1/cardview-v7-21.0.0-rc1.aar cardview-v7-21.0.0-rc1.zip
unzip cardview-v7-21.0.0-rc1.zip
mkdir libs/
mv classes.jar libs/cardview-v7-21.0.0-rc1.jar
나는 그 두 가지를 함께 추가 한 후에야 그것을 해결할 수 있었다.
dependencies {
...
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
...
}
내 build.gradle (Module : app) 파일
그런 다음 지금 동기화 버튼을 누릅니다.
Although a bit hidden it's in the official docs here where can the library be found among the sdk's code, and how to get it with resources (the Eclipse way)
From: https://developer.android.com/tools/support-library/setup.html#libs-with-res
Adding libraries with resources To add a Support Library with resources (such as v7 appcompat for action bar) to your application project:
Using Eclipse
Create a library project based on the support library code:
Make sure you have downloaded the Android Support Library using the SDK Manager.
Create a library project and ensure the required JAR files are included in the project's build path:
Select File > Import.
Select Existing Android Code Into Workspace and click Next.
Browse to the SDK installation directory and then to the Support Library folder. For example, if you are adding the appcompat project, browse to /extras/android/support/v7/appcompat/.
Click Finish to import the project. For the v7 appcompat project, you should now see a new project titled android-support-v7-appcompat.
In the new library project, expand the libs/ folder, right-click each .jar file and select Build
Path > Add to Build Path. For example, when creating the the v7 appcompat project, add both the android-support-v4.jar and android-support-v7-appcompat.jar files to the build path.
Right-click the library project folder and select Build Path > Configure Build Path.
In the Order and Export tab, check the .jar files you just added to the build path, so they are available to projects that depend on this library project. For example, the appcompat project requires you to export both the android-support-v4.jar and android-support-v7-appcompat.jar files.
Uncheck Android Dependencies.
Click OK to complete the changes.
You now have a library project for your selected Support Library that you can use with one or more application projects.
Add the library to your application project:
In the Project Explorer, right-click your project and select Properties.
In the category panel on the left side of the dialog, select Android.
In the Library pane, click the Add button.
Select the library project and click OK. For example, the appcompat project should be listed as android-support-v7-appcompat.
In the properties window, click OK.
Maybe it's a little bit late to add answer here. But I think this answer will help the later ones and especially those who don't want to use Android Studio.
Although the documents says that RecyclerView and CardView are part of v7 appcompat library. But as I tried and found, RecyclerView and CardView are actually depend on v7 appcompat library. So if you want to use RecyclerView or CardView, you need to add both v7 appcompat library and RecyclerView/CardView.
Referencing the link here, if you want to use CardView in your Eclipse android project, you need to import both v7 appcompat library and CardView into Eclipse workspace and make them as library projects. Then make CardView project depends on v7 appcompat library project and make your project depends on CardView project.
Simply add the following line in your build.gradle
project
dependencies {
...
compile 'com.android.support:cardview-v7:24.0.0'
}
And sync the project with gradle.
I did what FD_ said and it crashed with errors as it was looking for "Landroid/support/v7/cardview/R$styleable;", which was not compiled with it
If you really want to use CardView before in eclipse before it gets its own library, you can extract the classes from the classes.jar, copy and paste them into your project, with the values.xml from above from Android Studio and change all the references to android.support.v7.R to yourpackagename.R in the copied classes. This worked and ran for me
'code' 카테고리의 다른 글
Go에서 여러 명령을 파이프하는 방법은 무엇입니까? (0) | 2020.12.06 |
---|---|
NSUserDefaults에서 모든 값을 얻는 방법이 있습니까? (0) | 2020.12.06 |
빌드 도구 개정판 21.1.1을 찾지 못했습니다-최신 SDK (0) | 2020.12.06 |
Postgresql에서 캐리지 리턴과 새 줄을 제거하는 방법은 무엇입니까? (0) | 2020.12.06 |
Mac의 $ PATH에서 항목을 제거하는 방법 (0) | 2020.12.06 |