使用RecyclerView商品左右分类列表

最近自己想写一个购物类App 所以就模仿着网易严选的样式去写  今天刚好也写到分类这一块 看着这样的样式前面自己是想用两个LIstView去完成 后面想了想打算用 RecyclerView写 ,然后在百度上找了一些dome 。其实网上也有很多人写了这样的文章   自己为什么要写呢   第一自己写的话可以加深自己的理解第二如果哪天用到了可以直接来自己的博客上找

好了 其他也不做说明 下面看看我写出来的效果图

 

在使用RecyclerView 要在gradle上添加

compile 'com.android.support:design:25.1.1'

 首先我们使用的是 两个RecyclerView所以我们的布局是这样子的如果你使用的 linearLayout 布局的话记得加上android:orientation="horizontal"

<android.support.v7.widget.RecyclerView
    android:id="@+id/classify_left_list"
    android:layout_width="@dimen/two_fifty_six"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:background="@color/white"
    android:scrollbars="none" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:layout_weight="2">
    <ImageView
        android:id="@+id/series_image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:src="@mipmap/star_pager"
        />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textSize="@dimen/twenty_four"
        android:text="-- 列表 --"/>
    <android.support.v7.widget.RecyclerView
        android:id="@+id/classify_right_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none" />
</LinearLayout>
在接下来就是编写两个Adapter了 首先我们来写左边这个

public class ClassifyLeftAdapter extends RecyclerView.Adapter {
    private Context mContext;

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值