当前位置:首页 » 操作系统 » supportv7源码

supportv7源码

发布时间: 2024-06-20 00:45:00

㈠ android studio 中java文件提示android.support.v7.app.actionbaractivity is deprecated怎样处理

出这个提示的地方有写解决办法呀.

android.support.v7.app.ActionBarActivity is deprecated; useAppCompatActivity instead


意思是ActionBarActivity 在最新版本的support v7包里面已经不建议使用,建议用AppCompatActivity 这个类替代它.


所以解决办法很简单啊,把ActionBarActivity 直接换成AppCompatActivity 就可以了.


其实如果你看源码的话,这个AppCompatActivity 就和原来的ActionBarActivity 一模一样.它继承自ActionBarActivity, 但什么也没有复写.

packageandroid.support.v7.app;
/**
*@deprecatedUse{@linkandroid.support.v7.app.AppCompatActivity}instead.
*/
@Deprecated
{
}

㈡ android 安卓 类似ONE卡片页(包含图片文字等)怎么实现

Android5.0中向我们介绍了一个全新的控件–CardView,从本质上看,可以将CardView看做是FrameLayout在自身之上添加了圆角和阴影效果。请注意:CardView被包装为一种布局,并且经常在ListView和RecyclerView的Item布局中,作为一种容器使用。

下面例子来源于android学习手册, android学习手册包含9个章节,108个例子,源码文档随便看,例子都是可交互,可运行,源码采用android studio目录结构,高亮显示代码,文档都采用文档结构图显示,可以快速定位。360手机助手中下载,排在第四个。

CardView应该被使用在显示层次性的内容时;在显示列表或网格时更应该被选择,因为这些边缘可以使得用户更容易去区分这些内容。

使用CardView

首先,假设你的布局如同下面的形式:

<FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <!-- Main Content View --> <RelativeLayout> ... </RelativeLayout> </FrameLayout>

为了使用上面的布局方式来创建一个卡片,首先你需要导入支持的依赖库(android-support-v7-cardview的jar包)在你的build.gradle文件中。

dependencies { ... compile 'com.android.support:cardview-v7:21.0.2' }

现在将FrameLayout替换为CardView,

<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <!-- Main Content View --> <RelativeLayout> ... </RelativeLayout> </android.support.v7.widget.CardView>

就是这样!使用依赖库能够保证你的程序稳定的兼容之前的版本;尽管在AndroidL和之前的Android版本中对其处理方式有所不同。

㈢ 源码打包apk使用RecyclerView时遇到的坑

最近在做一个系统通知栏的项目叫MsgCenter。使用Android studio开发的.
使用了脚本拷贝与复制

LIBS="/Users/love/Desktop/moran2/MsgCenter/app/libs"
SRC="/Users/love/Desktop/moran2/MsgCenter/app/src/main/java/*"
RES="/Users/love/Desktop/moran2/MsgCenter/app/src/main/res"

ANDROIDMANIFEST="app/src/main/AndroidManifest.xml"

DES="/Users/love/Desktop/moran2/MsgCenter/MsgCenter"

mkdir -p $DES/src

cp -r LIBS DES
cp -r SRC DES/src
cp -r RES DES
cp -r JNI DES
cp ANDROIDMANIFEST DES
cp ANDROIDMK DES
然后提交到服务器打包报错:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: net.imoran.notification.lib, PID: 2630
java.lang.ExceptionInInitializerError
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115)
at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32)
at android.app.ActivityThread.handleBindService(ActivityThread.java:3158)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5795) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724)
Caused by: android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class android.support.v7.widget.RecyclerView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:123)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:34)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager .(NotificationWindowManager.java:111) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115) at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32) at android.app.ActivityThread.handleBindService(ActivityThread.java:3158) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5795)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724) Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class android.support.v7.widget.RecyclerView at android.view.LayoutInflater.createView(LayoutInflater.java:645) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.(NotificationWindowManager.java:123) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.(NotificationWindowManager.java:34) at net.imoran.notification.lib.windowmanager.NotificationWindowManager .<clinit>(NotificationWindowManager.java:111)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115)
at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32)
at android.app.ActivityThread.handleBindService(ActivityThread.java:3158)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5795) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:123)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:34)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager .(NotificationWindowManager.java:111) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115) at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32) at android.app.ActivityThread.handleBindService(ActivityThread.java:3158) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5795)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724) Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/recyclerview/R styleable;
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:590)
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:551)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:123)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:34)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager .(NotificationWindowManager.java:111) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115) at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32) at android.app.ActivityThread.handleBindService(ActivityThread.java:3158) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5795)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724) Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.recyclerview.R styleable" on path: DexPathList[[zip file "/flysystem/app/mor-notification.apk"],nativeLibraryDirectories=[/system/lib64/mor-notification, /flysystem/app/mor-notification.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:590)
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:551)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:123)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:34)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager .(NotificationWindowManager.java:111) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115) at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32) at android.app.ActivityThread.handleBindService(ActivityThread.java:3158) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5795)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724) Suppressed: java.lang.ClassNotFoundException: android.support.v7.recyclerview.R styleable
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 28 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
07-20 14:14:31.557 2630-2664/net.imoran.notification.lib I/System: FinalizerDaemon: finalize objects = 2695

从log中我们可以看到,
1.Binary XML file line #22: Binary XML file line #39: Error inflating class android.support.v7.widget.RecyclerView

2.同时还有这样的 java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/recyclerview/R$styleable

3.Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.recyclerview.R$styleable"

一开始只注意到了第一点,于是在网络上查呀查:
就发现大家的说法就是 在eclipse或者android studio上 因为sdk的版本不match,等等的。有的人说把android.support.v7.recyclerview.jar这个包换掉,换成match的版本的就好了,但我这边因为开发方式不一样,就又断掉了。但是却让我知道了是版本的问题

后来
有的人说是
1.AndroidManifest.xml中的targetSDKVersion不对,fix -> NOK。
2.build.gradle中的某些属性不对。fix -> NOK

因为App是独立的apk,就去这5.0,6.0 andorid 的源码中去找android.support.v7.recyclerview.

同时又注意到了这两点错误
2.同时还有这样的 java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/recyclerview/R$styleable

3.Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.recyclerview.R$styleable"

从Log中我们可以看到
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:440)
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:409)
RecyclerView的409 和 440 行出错

就发现了在 frameworks/support/v7/recyclerview/src/android/support/v7/widget/RecyclerView.java中

使用到了R.styleable.RecyclerView这个属性,而第2,3点log中出现的就是R$styleable 的错误。

明确了:在android6.0版本RecyclerView类中用到了R.styleable.RecyclerView这个资源。而android5.0的版本中的RecyclerView类没用到R.styleable.RecyclerView

回到frameworks/support/v7/recyclerview/目录下就会发现
-----------5.0 没有res/ 文件夹
-----------6.0 则有

那么现在中场总结一下,因为andorid5.0中的RexyclerView类中没有使用res资源,而6.0却使用了。同时6.0的res/资源是存在的。只能说明,我们没有引用到,或者说是没有把对应的资源加载,进行编译

问题又来了:res/资源是在哪里加载的?

----------》 Android.mk 文件下有这么一段

发现了android-support-v7-recyclerview的身影

那这内容是什么意思?

1.LOCAL_STATIC_JAVA_LIBARIES 本地静态java库。
2.LOCAL_RESOURCE_DIR 本地资源文件,默认是proct package和device package下面相应的res路径和$(LOCAL_PATH)/res
3.LOCAL_AAPT_FLAGS += -c ldpi -c mdpi
上面指定了编译时打包 ldpi 和mdpi 如果系统默认的是hdpi的话,那就是这三种都会装入包中

在中场总结的时候,已经明确,是因为res资源没有加载。
所以只需要在LOCAL_RESOURCE_DIR中加上frameworks/support/v7/recyclerview/res就可以了

Android.mk文件内容变成:

再次编译,正常运行。

======================================================================================================
其实就是因为android的版本升级,RecyclerView 中的创建LayoutManager的方式发生了改变,旧版本里少了个 R.styleable.RecyclerView, 而在新环境下又没将其编译进去,故有此错。

各位少侠也可以在 package 中的res/attrs.xml 下面自己定义一个`````

总体来说将的不是很清楚, 还请大家见谅 。。

㈣ Android Studio项目 v7包版本和依赖库v7包版本不一致警告怎么解决

默认使用最新版本
否则library moudle引入源码改版本

㈤ 如何在Android Studio中添加RecyclerView-v7支持包

Android 5.0新特性中出现了一个非常牛逼的控件——RecyclerView。默认情况下,Android Studio当前的支持包中没有引入RecyclerView的v7包,所以当我们直接输入Recycle时提示中没有RecyclerView。这里要介绍的是如何在Android studio中引入支持RecyclerView的v7包。

前提是已经下载了Android Support Library支持包,一般是自动就下载好了。如果没有下载,就打开SDK Manager下载喽!
一、
1.在Project模式下,点开External Libraries,可以看到只有appcompat-v7-23.4.0(这是我自己下载的版本)这个v7包,通过查看其属性可以找到源码位置

二、其实还可以这样做:
在源码位置可以找到recyclerview-v7-23.4.0-sources.jar,将其复制到libs目录下同样可以达到目的。

热点内容
登陆社保账号密码是什么 发布:2024-11-26 16:23:03 浏览:896
优盾加密软件 发布:2024-11-26 16:15:52 浏览:655
热血传奇手游免费辅助脚本 发布:2024-11-26 15:59:03 浏览:220
安卓王者荣耀怎么设置回复血量 发布:2024-11-26 15:58:58 浏览:533
汽车空调压缩机轴承 发布:2024-11-26 15:58:56 浏览:960
c语言中53 发布:2024-11-26 15:56:36 浏览:281
ftp上传浏览器 发布:2024-11-26 15:39:56 浏览:788
mvc数据访问层 发布:2024-11-26 15:39:36 浏览:259
安卓的face怎么使用 发布:2024-11-26 15:05:50 浏览:90
存储魔力象限2016 发布:2024-11-26 15:04:47 浏览:867