The invention relates to the field of Android software development. The high-version SDK issued by Google can not solve the serious problem of software fragmentation developed on low-version SDK. An optimization method of fragment view caching is proposed, which includes the following steps: Step 1, creating a class inherited from Fragment class as a parent class, overwriting the onCreateView method in the parent class, and overwriting the onCreateV caching method in the onCreateV class. The view is cached in iew method; Step 2: Create a Fragment subclass inheriting the view layout from the parent class. In the onCreateView method of the Fragment subclass, super keywords are used to refer to the onCreateView method of the parent class. This method improves the efficiency of view caching and the maintainability of code. It is suitable for fragmented view caching optimization of Android version 4.0 or more.
【技术实现步骤摘要】
碎片视图缓存的优化方法
本专利技术涉及Android软件开发领域,特别涉及一种碎片视图缓存的优化方法。
技术介绍
安卓开发依赖于谷歌的安卓系统平台,但由于是开源的系统,导致安卓碎片化严重。对于视图的缓存,谷歌在发布的Android6.0系统中进行了优化并发布了对应的SDK,但是用户使用的系统版本分层多,系统定制大且各大手机厂商发布的平台也多,上述优化的SDK无法应用在低版本的系统上,那么就需要有一种自定义的基于低版本例如安卓4.0的SDK来实现向上兼容所有版本不同平台的多碎片视图缓存的方法。传统的多个Fragment(碎片)之间的数据传递需依赖于Activity(活动)类在嵌套Fragment类时进行构造,多个fragment类需要使用软缓存的情况下,需要对每个fragment类对象都进行View类的缓存处理,导致重复性代码多及代码量大,进一步带来视图缓存效率低下及维护成本高的问题。
技术实现思路
本专利技术所要解决的技术问题是:克服谷歌发出的基于高版本的SDK无法解决已有的基于低版本SDK上开发的软件碎片化严重的问题,提出一种碎片视图缓存的优化方法。本专利技术解决上 ...
【技术保护点】
1.碎片视图缓存的优化方法,其特征在于,包括如下步骤:步骤1、创建继承于Fragment类的类作为父类,在该父类中覆写onCreateView方法,在该onCreateView方法中进行视图的缓存处理;步骤2、创建需要视图布局的继承于所述父类的Fragment子类,在Fragment子类中覆写onCreateView方法,在Fragment子类的onCreateView方法中采用super关键词来引用父类的onCreateView方法进行视图的缓存处理。
【技术特征摘要】
1.碎片视图缓存的优化方法,其特征在于,包括如下步骤:步骤1、创建继承于Fragment类的类作为父类,在该父类中覆写onCreateView方法,在该onCreateView方法中进行视图的缓存处理;步骤2、创建需要视图布局的继承于所述父类的Fragment子类,在Fragment子类中覆写onCreateView方法,在Fragment子类的onCreateView方法中采用super关键词来引用父类的onCreateView方法进行视图的缓存处理。2.如权利要求1所述的碎片视图缓存的优化方法,其特征在于,所述步骤2之前还包括创建单例工厂类,在该单例工厂类里创建静态的Bundle对象并公开该Bundle对象的存入方法和取出方法;所述步骤2中,Fragment子类采用super关键词来引用...
【专利技术属性】
技术研发人员:文卉,柳田泽,戴德军,
申请(专利权)人:四川爱创科技有限公司,
类型:发明
国别省市:四川,51
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。