Android5.0练习

   这时一个练习5.0新特性的小项目,bug还有不少,适合借鉴用,新手写博客 没啥拿的出手的东西,大家互相学习,欢迎吐槽

其中RecyclerView的下啦刷新 上拉加载 借鉴了http://www.cnblogs.com/tiantianbyconan/p/4242541.html


主页布局文件:

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/coordinatorLayout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:fitsSystemWindows="true"
    android:clipToPadding="true"
    >

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:minHeight="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            />
        <FrameLayout
            android:id="@+id/id_content"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            ></FrameLayout>
    </android.support.design.widget.AppBarLayout>
    <include layout="@layout/bottom" />
</android.support.design.widget.CoordinatorLayout>
     首先最外层就是4块大的fragment,每个大fragment中的模式都是sildingTabLayout+viewpager+fragment,我也不知道这样嵌套有啥弊端,不过这个例子就这么用了,大家有啥好建议欢迎吐槽。

    最开始没用sildingTabLayout用的是design包中的TabLayout,但是有个问题,第一个大的

fragment中的显示是没问题的,但是后面的大fragment中TabLayout中就不显示数据了,找了半天也没找到原因,后来就换成了现在这个sildingTabLayout,如果有知道的朋友可以告诉我哦,多谢啦!  
     后来又有问题第一个大fragment中的小fragment没数据,后来发现是我吧(sildingTabLayout+viewpager+fragment)写在了fragment中,那么创建viewpager的adapter的时候传入的参数不能是FragmentManager() 应该是 getChildFragmentManager() 这样数据终于显示正常。

网络连接用的是鸿大神封装的okHttp,最开始的一版,后来好像有更简单点的
图片缓存用的是picasso,这个框架还是很好用的,代码量很少很简单。项目中有的图片好像拉伸活压缩了,这个具体工作中可以根据显示需要规定好图片尺寸,这些图片只是网上找的
toolbar的menu菜单中添加一个zxing二维码扫描,扫描后的结果没做处理,如有用到可以在MipcaActivityCapture 类中的handleDecode方法中处理。

项目下载地址 https://github.com/caoweiaaa/lifebao

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值