Andriod studio 學習 之 Recyclerview

Recyclerview

RecyclerView的優點

1.RecyclerView比listview實現效果更多
2.RecycelrView支持多佈局;
3.RecyclerView根據項目需要插拔功能 RecyclerView默認不支持點擊事件->程序員代碼中通過回調接口的方式添加監聽

重要的方法

1.RecyclerView橫向滑動:
LinearLayoutManager.HORIZONTAL橫向滑動LinearLayoutManager.VERTICAL垂直滑動

2.RecyclerView.Adapter中刷新方法區別:
notifyDataSetChanged();整體刷新+沒有動畫效果
notifyItemInserted(int position,Object data):有動畫效果+添加一條數據在position位置
notifyItemRemoved(position);有動畫效果+刪除一條數據並刷新
注意:當添加和刪除的時候,要更新下標,不然有錯位現象

3.RecyclerView多佈局展示:
public int getItemViewType(int position)返回當前數據的itemview類型
4.RecyclerView常見方法:
LinearLayoutManager:recyclerview線性管理器(垂直水平方向);
GridLayoutManager:網格佈局管理器;
StaggeredGridLayoutManager:瀑布流佈局管理器;
RecyclerView.setLayoutManager(LayoutManager manager):添加布局管理器
RecyclerView.addItemDecoration(ItemDecoration decoration):添加分割線
RecyclerView.setItemAnimator(ItemAnimator animator):添加動畫方法

效果展示

在這裏插入圖片描述

代碼

首先需要導入依賴

implementation ‘com.android.support:recyclerview-v7:28.0.0’

xml佈局

<?xml version="1.0" encoding="utf-8"?>

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
Activity的代碼
    public class MainActivity extends AppCompatActivity {
    ArrayList<Bean.DataBean> list=new ArrayList<>();
    RecyclerView recycler;
    Recycleradpater adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        recycler = (RecyclerView) findViewById(R.id.recycler);

        adapter=new Recycleradpater(list,this);
        recycler.setAdapter(adapter);
        //設置佈局方式
        //   recyclerView.setLayoutManager(new LinearLayoutManager(this));//線性佈局
        //   recyclerView.setLayoutManager(new GridLayoutManager(this,3));//網格
        recycler.setLayoutManager(new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL));//瀑布流
        adapter.setMyItemListener(new MyItemListener() {
            @Override
            public void onItemClick(int position) {
                Intent intent = new Intent(MainActivity.this, Main2Activity.class);
                intent.putExtra("videouri",list.get(position).getVideouri());//視頻網址
                startActivity(intent);
            }
        });
        initData();
    }
    private void initData() {
        OkGo.<String>get("https://www.apiopen.top/satinApi?type=1&page=2").execute(new StringCallback() {
            @Override
            public void onSuccess(Response<String> response) {
                String json = response.body();
                Toast.makeText(MainActivity.this, "", Toast.LENGTH_SHORT).show();
                Gson gson = new Gson();
                Bean bean = gson.fromJson(json, Bean.class);
                List<Bean.DataBean> data = bean.getData();
                list.addAll(data);
                adapter.notifyDataSetChanged();
            }
        });
    }
}

適配器中的代碼

   public class Recycleradpater extends RecyclerView.Adapter<Recycleradpater.Viewholder> {
    ArrayList<Bean.DataBean> list;
    Context context;
    private MyItemListener myItemListener;

    public void setMyItemListener(MyItemListener myItemListener) {
        this.myItemListener = myItemListener;
    }

    public Recycleradpater(ArrayList<Bean.DataBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @NonNull
    @Override
    public Viewholder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(context).inflate(R.layout.item, viewGroup, false);
        return new Viewholder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull Viewholder viewholder, final int i) {
        viewholder.textView.setText(list.get(i).getText());
        Glide.with(context).load(list.get(i).getImage1()).into(viewholder.imageView);
        viewholder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                myItemListener.onItemClick(i);
            }
        });
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class Viewholder extends RecyclerView.ViewHolder {
        TextView textView;
        ImageView imageView;
        public Viewholder(@NonNull View itemView) {
            super(itemView);
            textView=itemView.findViewById(R.id.tv);
            imageView=itemView.findViewById(R.id.iv);
        }
    }
}

Bean類

package com.example.recyclerview;

import java.util.List;

public class Bean {
    /**
     * code : 200
     * msg : 成功!
     * data : [{"type":"41","text":"35秒絕殺,你依然是少年!","user_id":"23077898","name":"誕誕的小迷妹","screen_name":"誕誕的小迷妹","profile_image":"http://wimg.spriteapp.cn/profile/20190413144916106080.jpg","created_at":"2019-09-05 06:57:02","create_time":null,"passtime":"2019-09-05 06:57:02","love":"263","hate":"8","comment":"20","repost":"25","bookmark":"0","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"58191","theme_name":"搞笑視頻","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.mp4","videotime":131,"original_pid":"0","cache_version":2,"playcount":"7791","playfcount":"69","cai":"8","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.jpg","width":"480","height":"852","tag":"","t":1567637822,"ding":"263","favourite":"0","top_cmt":null,"themes":null},{"type":"10","text":"學校大掃除正在擦玻璃的你","user_id":"23125790","name":"得瑟的人生","screen_name":"得瑟的人生","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/07/04/5d1d6a9be047d_mini.jpg","created_at":"2019-09-05 06:36:02","create_time":null,"passtime":"2019-09-05 06:36:02","love":"76","hate":"7","comment":"9","repost":"2","bookmark":"0","bimageuri":"","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"58240","theme_name":"搞笑圖片","theme_type":"1","videouri":"","videotime":0,"original_pid":"0","cache_version":2,"playcount":null,"playfcount":null,"cai":"7","weixin_url":null,"image1":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e4338ec463.gif","image2":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e4338ec463.gif","is_gif":false,"image0":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e4338ec463.gif","image_small":null,"cdn_img":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e4338ec463.gif","width":"320","height":"298","tag":"","t":1567636562,"ding":"76","favourite":"0","top_cmt":null,"themes":null},{"type":"41","text":"你認識的山東人也是這麼說話的麼?","user_id":"20746662","name":"櫻花⌒識盈","screen_name":"櫻花⌒識盈","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/03/26/5c99f6da2b8b4_mini.jpg","created_at":"2019-09-05 06:17:03","create_time":null,"passtime":"2019-09-05 06:17:03","love":"249","hate":"5","comment":"20","repost":"10","bookmark":"0","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0904/733d8b90-cec4-11e9-b5c0-1866daeb0df1_wpd.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"58191","theme_name":"搞笑視頻","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0904/733d8b90-cec4-11e9-b5c0-1866daeb0df1_wpd.mp4","videotime":91,"original_pid":"0","cache_version":2,"playcount":"10265","playfcount":"21","cai":"5","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0904/733d8b90-cec4-11e9-b5c0-1866daeb0df1_wpd.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0904/733d8b90-cec4-11e9-b5c0-1866daeb0df1_wpd.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0904/733d8b90-cec4-11e9-b5c0-1866daeb0df1_wpd.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0904/733d8b90-cec4-11e9-b5c0-1866daeb0df1_wpd.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0904/733d8b90-cec4-11e9-b5c0-1866daeb0df1_wpd.jpg","width":"1066","height":"600","tag":"","t":1567635423,"ding":"249","favourite":"0","top_cmt":null,"themes":null},{"type":"10","text":"看了這個動圖,你就知道什麼叫做\u201c當媽的本能\u201d","user_id":"","name":"","screen_name":"","profile_image":"","created_at":"2019-09-05 05:56:02","create_time":null,"passtime":"2019-09-05 05:56:02","love":"108","hate":"6","comment":"28","repost":"2","bookmark":"2","bimageuri":"","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"58240","theme_name":"搞笑圖片","theme_type":"1","videouri":"","videotime":0,"original_pid":"0","cache_version":2,"playcount":null,"playfcount":null,"cai":"6","weixin_url":null,"image1":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e52c6eb292.gif","image2":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e52c6eb292.gif","is_gif":false,"image0":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e52c6eb292.gif","image_small":null,"cdn_img":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e52c6eb292.gif","width":"642","height":"480","tag":"","t":1567634162,"ding":"108","favourite":"2","top_cmt":null,"themes":null},{"type":"41","text":"哈哈哈哈哈有沒有get到同款啊","user_id":"20746662","name":"櫻花⌒識盈","screen_name":"櫻花⌒識盈","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/03/26/5c99f6da2b8b4_mini.jpg","created_at":"2019-09-05 05:37:02","create_time":null,"passtime":"2019-09-05 05:37:02","love":"395","hate":"6","comment":"26","repost":"20","bookmark":"3","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0904/29751643_302.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"58191","theme_name":"搞笑視頻","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0904/c8453cfa-cec4-11e9-8889-1866daea6abd_wpd.mp4","videotime":146,"original_pid":"0","cache_version":2,"playcount":"9331","playfcount":"59","cai":"6","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0904/29751643_302.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0904/29751643_302.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0904/29751643_302.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0904/29751643_302.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0904/29751643_302.jpg","width":"544","height":"960","tag":"","t":1567633022,"ding":"395","favourite":"3","top_cmt":null,"themes":null},{"type":"41","text":"額\u2026交女朋友千萬別認識她的閨蜜","user_id":"20746563","name":"靈魂遐想","screen_name":"靈魂遐想","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/03/26/5c99f6e2178a1_mini.jpg","created_at":"2019-09-05 04:57:02","create_time":null,"passtime":"2019-09-05 04:57:02","love":"219","hate":"8","comment":"26","repost":"7","bookmark":"0","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0904/f4676424-cee8-11e9-95a0-1866daeb0df1_wpd.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"58191","theme_name":"搞笑視頻","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0904/f4676424-cee8-11e9-95a0-1866daeb0df1_wpd.mp4","videotime":33,"original_pid":"0","cache_version":2,"playcount":"4097","playfcount":"323","cai":"8","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0904/f4676424-cee8-11e9-95a0-1866daeb0df1_wpd.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0904/f4676424-cee8-11e9-95a0-1866daeb0df1_wpd.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0904/f4676424-cee8-11e9-95a0-1866daeb0df1_wpd.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0904/f4676424-cee8-11e9-95a0-1866daeb0df1_wpd.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0904/f4676424-cee8-11e9-95a0-1866daeb0df1_wpd.jpg","width":"852","height":"480","tag":"","t":1567630622,"ding":"219","favourite":"0","top_cmt":null,"themes":null},{"type":"41","text":"開學的真實感受","user_id":"23123011","name":"安磨先生","screen_name":"安磨先生","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/07/03/5d1c79d9b806d_mini.jpg","created_at":"2019-09-05 04:16:02","create_time":null,"passtime":"2019-09-05 04:16:02","love":"63","hate":"1","comment":"9","repost":"0","bookmark":"2","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e5ffda2a89_wpd.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"58191","theme_name":"搞笑視頻","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0903/5d6e5ffda2a89_wpd.mp4","videotime":13,"original_pid":"0","cache_version":2,"playcount":"758","playfcount":"82","cai":"1","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e5ffda2a89_wpd.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e5ffda2a89_wpd.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e5ffda2a89_wpd.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e5ffda2a89_wpd.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e5ffda2a89_wpd.jpg","width":"480","height":"480","tag":"","t":1567628162,"ding":"63","favourite":"2","top_cmt":null,"themes":null},{"type":"41","text":"夕陽灑向了地中海,真美。","user_id":"23130462","name":"瓊都歌舞廳","screen_name":"瓊都歌舞廳","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/07/04/5d1d8a09e5c85_mini.jpg","created_at":"2019-09-05 03:36:02","create_time":null,"passtime":"2019-09-05 03:36:02","love":"71","hate":"3","comment":"4","repost":"0","bookmark":"0","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0904/29751804_469.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"58191","theme_name":"搞笑視頻","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0904/5d6f410614ef9_wpd.mp4","videotime":11,"original_pid":"0","cache_version":2,"playcount":"1137","playfcount":"127","cai":"3","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0904/29751804_469.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0904/29751804_469.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0904/29751804_469.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0904/29751804_469.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0904/29751804_469.jpg","width":"576","height":"1024","tag":"","t":1567625762,"ding":"71","favourite":"0","top_cmt":null,"themes":null},{"type":"41","text":"女生都這麼會玩嗎","user_id":"23146760","name":"笑笑不說話1","screen_name":"笑笑不說話1","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/08/17/5d57dc9ee77b2_mini.jpg","created_at":"2019-09-05 02:56:02","create_time":null,"passtime":"2019-09-05 02:56:02","love":"80","hate":"6","comment":"3","repost":"2","bookmark":"1","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e09081b465__b.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"58191","theme_name":"搞笑視頻","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0903/5d6e090829e0e_wpd.mp4","videotime":19,"original_pid":"0","cache_version":2,"playcount":"1766","playfcount":"187","cai":"6","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e09081b465__b.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e09081b465__b.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e09081b465__b.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e09081b465__b.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e09081b465__b.jpg","width":"1066","height":"600","tag":"","t":1567623362,"ding":"80","favourite":"1","top_cmt":null,"themes":null},{"type":"10","text":"小小年紀就喜歡捉弄大人","user_id":"23129236","name":"默笙","screen_name":"默笙","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/07/04/5d1d74b427cae_mini.jpg","created_at":"2019-09-05 02:52:01","create_time":null,"passtime":"2019-09-05 02:52:01","love":"99","hate":"4","comment":"8","repost":"1","bookmark":"1","bimageuri":"","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"56781","theme_name":"情感社區","theme_type":"1","videouri":"","videotime":0,"original_pid":"0","cache_version":2,"playcount":null,"playfcount":null,"cai":"4","weixin_url":null,"image1":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e2405406f3.gif","image2":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e2405406f3.gif","is_gif":false,"image0":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e2405406f3.gif","image_small":null,"cdn_img":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e2405406f3.gif","width":"200","height":"300","tag":"","t":1567623121,"ding":"99","favourite":"1","top_cmt":null,"themes":null},{"type":"41","text":"第一次發,試試咋回事","user_id":"23156526","name":"友誼之光","screen_name":"友誼之光","profile_image":"http://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTIMBAbbvdc0Ljc08RamyagUHy9mv3qkJMDu9MxXRHJbxTuVeOPLFWXk4OBtN52VXzOA0PGVHgt4pw/132","created_at":"2019-09-05 02:16:01","create_time":null,"passtime":"2019-09-05 02:16:01","love":"108","hate":"5","comment":"6","repost":"2","bookmark":"0","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e5269302f5_wpd.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"55163","theme_name":"主版塊","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0903/5d6e5269302f5_wpd.mp4","videotime":12,"original_pid":"0","cache_version":2,"playcount":"3438","playfcount":"455","cai":"5","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e5269302f5_wpd.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e5269302f5_wpd.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e5269302f5_wpd.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e5269302f5_wpd.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e5269302f5_wpd.jpg","width":"272","height":"480","tag":"","t":1567620961,"ding":"108","favourite":"0","top_cmt":null,"themes":null},{"type":"10","text":"慢點拍、相機着急着還嗎","user_id":"10310000","name":"麝香夫人","screen_name":"麝香夫人","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/01/06/5c31c959dd66c_mini.jpg","created_at":"2019-09-05 01:56:01","create_time":null,"passtime":"2019-09-05 01:56:01","love":"70","hate":"7","comment":"2","repost":"1","bookmark":"6","bimageuri":"","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"55163","theme_name":"主版塊","theme_type":"1","videouri":"","videotime":0,"original_pid":"0","cache_version":2,"playcount":null,"playfcount":null,"cai":"7","weixin_url":null,"image1":"http://wimg.spriteapp.cn/ugc/2019/09/02/5d6c8c7a8f047.gif","image2":"http://wimg.spriteapp.cn/ugc/2019/09/02/5d6c8c7a8f047.gif","is_gif":false,"image0":"http://wimg.spriteapp.cn/ugc/2019/09/02/5d6c8c7a8f047.gif","image_small":null,"cdn_img":"http://wimg.spriteapp.cn/ugc/2019/09/02/5d6c8c7a8f047.gif","width":"216","height":"384","tag":"","t":1567619761,"ding":"70","favourite":"6","top_cmt":null,"themes":null},{"type":"41","text":"我家貓出去一晚回來怎麼這樣了","user_id":"20272202","name":"淼兔兔i","screen_name":"淼兔兔i","profile_image":"http://wimg.spriteapp.cn/profile/large/2018/04/19/5ad85b1dc8973_mini.jpg","created_at":"2019-09-05 01:36:01","create_time":null,"passtime":"2019-09-05 01:36:01","love":"92","hate":"3","comment":"17","repost":"2","bookmark":"4","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e227c06e1c_wpd.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"55163","theme_name":"主版塊","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0903/5d6e227c06e1c_wpd.mp4","videotime":20,"original_pid":"0","cache_version":2,"playcount":"2586","playfcount":"757","cai":"3","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e227c06e1c_wpd.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e227c06e1c_wpd.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e227c06e1c_wpd.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e227c06e1c_wpd.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e227c06e1c_wpd.jpg","width":"600","height":"1066","tag":"","t":1567618561,"ding":"92","favourite":"4","top_cmt":null,"themes":null},{"type":"41","text":"大半夜看的淚奔,好想回到小時候每一個睡醒了午覺,抱着冰淇淋打開電視機的日子。","user_id":"20746554","name":"遊園驚夢","screen_name":"遊園驚夢","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/03/26/5c99f6e1b64ad_mini.jpg","created_at":"2019-09-05 00:56:01","create_time":null,"passtime":"2019-09-05 00:56:01","love":"236","hate":"4","comment":"31","repost":"26","bookmark":"6","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0904/375d6b50-cedc-11e9-b89c-1866daea6abd_wpd.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"56781","theme_name":"情感社區","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0904/375d6b50-cedc-11e9-b89c-1866daea6abd_wpd.mp4","videotime":72,"original_pid":"0","cache_version":2,"playcount":"5701","playfcount":"118","cai":"4","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0904/375d6b50-cedc-11e9-b89c-1866daea6abd_wpd.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0904/375d6b50-cedc-11e9-b89c-1866daea6abd_wpd.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0904/375d6b50-cedc-11e9-b89c-1866daea6abd_wpd.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0904/375d6b50-cedc-11e9-b89c-1866daea6abd_wpd.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0904/375d6b50-cedc-11e9-b89c-1866daea6abd_wpd.jpg","width":"480","height":"852","tag":"","t":1567616161,"ding":"236","favourite":"6","top_cmt":null,"themes":null},{"type":"10","text":"想必承受了很大的壓力","user_id":"23134166","name":"一抿解千愁","screen_name":"一抿解千愁","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/07/04/5d1da92205211_mini.jpg","created_at":"2019-09-05 00:36:01","create_time":null,"passtime":"2019-09-05 00:36:01","love":"72","hate":"13","comment":"16","repost":"1","bookmark":"1","bimageuri":"","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"60369","theme_name":"女神萌妹","theme_type":"1","videouri":"","videotime":0,"original_pid":"0","cache_version":2,"playcount":null,"playfcount":null,"cai":"13","weixin_url":null,"image1":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e62ec42297_1.jpg","image2":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e62ec42297_1.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e62ec42297_1.jpg","image_small":null,"cdn_img":"http://wimg.spriteapp.cn/ugc/2019/09/03/5d6e62ec42297_1.jpg","width":"1536","height":"4096","tag":"","t":1567614961,"ding":"72","favourite":"1","top_cmt":null,"themes":null},{"type":"41","text":"豬一樣的外國對友,防火防盜防閨蜜啊......","user_id":"18380255","name":"敏智的選擇","screen_name":"敏智的選擇","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/03/21/5c93280bb362e_mini.jpg","created_at":"2019-09-05 00:26:01","create_time":null,"passtime":"2019-09-05 00:26:01","love":"115","hate":"15","comment":"3","repost":"0","bookmark":"3","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e6136564c2_wpd.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"58191","theme_name":"搞笑視頻","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0903/5d6e6136564c2_wpd.mp4","videotime":143,"original_pid":"0","cache_version":2,"playcount":"3259","playfcount":"429","cai":"15","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e6136564c2_wpd.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e6136564c2_wpd.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e6136564c2_wpd.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e6136564c2_wpd.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e6136564c2_wpd.jpg","width":"366","height":"596","tag":"","t":1567614361,"ding":"115","favourite":"3","top_cmt":null,"themes":null},{"type":"41","text":"【蔬菜豆腐羹】1分鐘教你學會,做法簡單,營養又美味,美食get√","user_id":"20746886","name":"流年絮語","screen_name":"流年絮語","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/03/26/5c99f6dba8287_mini.jpg","created_at":"2019-09-04 23:56:01","create_time":null,"passtime":"2019-09-04 23:56:01","love":"448","hate":"10","comment":"7","repost":"12","bookmark":"12","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0904/73fa73ae-ceb5-11e9-b726-1866daea6abd_wpd.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"123","theme_name":"美食頻道","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0904/73fa73ae-ceb5-11e9-b726-1866daea6abd_wpd.mp4","videotime":30,"original_pid":"0","cache_version":2,"playcount":"9497","playfcount":"65","cai":"10","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0904/73fa73ae-ceb5-11e9-b726-1866daea6abd_wpd.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0904/73fa73ae-ceb5-11e9-b726-1866daea6abd_wpd.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0904/73fa73ae-ceb5-11e9-b726-1866daea6abd_wpd.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0904/73fa73ae-ceb5-11e9-b726-1866daea6abd_wpd.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0904/73fa73ae-ceb5-11e9-b726-1866daea6abd_wpd.jpg","width":"480","height":"852","tag":"","t":1567612561,"ding":"448","favourite":"12","top_cmt":null,"themes":null},{"type":"10","text":"母豬的產後護理。","user_id":"23125725","name":"單身狗協會會員","screen_name":"單身狗協會會員","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/07/04/5d1d6a8d95b4c_mini.jpg","created_at":"2019-09-04 23:56:01","create_time":null,"passtime":"2019-09-04 23:56:01","love":"79","hate":"6","comment":"2","repost":"0","bookmark":"0","bimageuri":"","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"58240","theme_name":"搞笑圖片","theme_type":"1","videouri":"","videotime":0,"original_pid":"0","cache_version":2,"playcount":null,"playfcount":null,"cai":"6","weixin_url":null,"image1":"http://wimg.spriteapp.cn/ugc/2019/08/27/5d64d0ba101f9.gif","image2":"http://wimg.spriteapp.cn/ugc/2019/08/27/5d64d0ba101f9.gif","is_gif":false,"image0":"http://wimg.spriteapp.cn/ugc/2019/08/27/5d64d0ba101f9.gif","image_small":null,"cdn_img":"http://wimg.spriteapp.cn/ugc/2019/08/27/5d64d0ba101f9.gif","width":"213","height":"311","tag":"","t":1567612561,"ding":"79","favourite":"0","top_cmt":null,"themes":null},{"type":"41","text":"兩個女人爲一個男的吵架是真的精彩刺激,女老闆的火力真的猛,實習小三不大行。","user_id":"20746665","name":"櫻花丶葬禮","screen_name":"櫻花丶葬禮","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/03/26/5c99f6da60550_mini.jpg","created_at":"2019-09-04 23:46:09","create_time":null,"passtime":"2019-09-04 23:46:09","love":"339","hate":"16","comment":"30","repost":"26","bookmark":"9","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0904/ca39e3ae-cec3-11e9-8889-1866daea6abd_wpd.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"407","theme_name":"影視分享","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0904/ca39e3ae-cec3-11e9-8889-1866daea6abd_wpd.mp4","videotime":446,"original_pid":"0","cache_version":2,"playcount":"7947","playfcount":"267","cai":"16","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0904/ca39e3ae-cec3-11e9-8889-1866daea6abd_wpd.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0904/ca39e3ae-cec3-11e9-8889-1866daea6abd_wpd.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0904/ca39e3ae-cec3-11e9-8889-1866daea6abd_wpd.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0904/ca39e3ae-cec3-11e9-8889-1866daea6abd_wpd.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0904/ca39e3ae-cec3-11e9-8889-1866daea6abd_wpd.jpg","width":"852","height":"480","tag":"","t":1567611969,"ding":"339","favourite":"9","top_cmt":null,"themes":null},{"type":"41","text":"肚皮疼不","user_id":"23155861","name":"充能君","screen_name":"充能君","profile_image":"http://wimg.spriteapp.cn/profile/large/2019/09/01/5d6bcf4e55de6_mini.png","created_at":"2019-09-04 23:36:01","create_time":null,"passtime":"2019-09-04 23:36:01","love":"84","hate":"4","comment":"21","repost":"1","bookmark":"0","bimageuri":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e2eefea346_wpd.jpg","voiceuri":null,"voicetime":null,"voicelength":null,"status":"4","theme_id":"55163","theme_name":"主版塊","theme_type":"1","videouri":"http://wvideo.spriteapp.cn/video/2019/0903/5d6e2eefea346_wpd.mp4","videotime":13,"original_pid":"0","cache_version":2,"playcount":"4751","playfcount":"471","cai":"4","weixin_url":null,"image1":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e2eefea346_wpd.jpg","image2":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e2eefea346_wpd.jpg","is_gif":false,"image0":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e2eefea346_wpd.jpg","image_small":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e2eefea346_wpd.jpg","cdn_img":"http://wimg.spriteapp.cn/picture/2019/0903/5d6e2eefea346_wpd.jpg","width":"368","height":"640","tag":"","t":1567611361,"ding":"84","favourite":"0","top_cmt":null,"themes":null}]
     */

    private int code;
    private String msg;
    private List<DataBean> data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public List<DataBean> getData() {
        return data;
    }

    public void setData(List<DataBean> data) {
        this.data = data;
    }

    public static class DataBean {
        /**
         * type : 41
         * text : 35秒絕殺,你依然是少年!
         * user_id : 23077898
         * name : 誕誕的小迷妹
         * screen_name : 誕誕的小迷妹
         * profile_image : http://wimg.spriteapp.cn/profile/20190413144916106080.jpg
         * created_at : 2019-09-05 06:57:02
         * create_time : null
         * passtime : 2019-09-05 06:57:02
         * love : 263
         * hate : 8
         * comment : 20
         * repost : 25
         * bookmark : 0
         * bimageuri : http://wimg.spriteapp.cn/picture/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.jpg
         * voiceuri : null
         * voicetime : null
         * voicelength : null
         * status : 4
         * theme_id : 58191
         * theme_name : 搞笑視頻
         * theme_type : 1
         * videouri : http://wvideo.spriteapp.cn/video/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.mp4
         * videotime : 131
         * original_pid : 0
         * cache_version : 2
         * playcount : 7791
         * playfcount : 69
         * cai : 8
         * weixin_url : null
         * image1 : http://wimg.spriteapp.cn/picture/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.jpg
         * image2 : http://wimg.spriteapp.cn/picture/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.jpg
         * is_gif : false
         * image0 : http://wimg.spriteapp.cn/picture/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.jpg
         * image_small : http://wimg.spriteapp.cn/picture/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.jpg
         * cdn_img : http://wimg.spriteapp.cn/picture/2019/0904/18c9c368-cec4-11e9-9d74-1866daeb0df1_wpd.jpg
         * width : 480
         * height : 852
         * tag :
         * t : 1567637822
         * ding : 263
         * favourite : 0
         * top_cmt : null
         * themes : null
         */

        private String type;
        private String text;
        private String user_id;
        private String name;
        private String screen_name;
        private String profile_image;
        private String created_at;
        private Object create_time;
        private String passtime;
        private String love;
        private String hate;
        private String comment;
        private String repost;
        private String bookmark;
        private String bimageuri;
        private Object voiceuri;
        private Object voicetime;
        private Object voicelength;
        private String status;
        private String theme_id;
        private String theme_name;
        private String theme_type;
        private String videouri;
        private int videotime;
        private String original_pid;
        private int cache_version;
        private String playcount;
        private String playfcount;
        private String cai;
        private Object weixin_url;
        private String image1;
        private String image2;
        private boolean is_gif;
        private String image0;
        private String image_small;
        private String cdn_img;
        private String width;
        private String height;
        private String tag;
        private int t;
        private String ding;
        private String favourite;
        private Object top_cmt;
        private Object themes;

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getText() {
            return text;
        }

        public void setText(String text) {
            this.text = text;
        }

        public String getUser_id() {
            return user_id;
        }

        public void setUser_id(String user_id) {
            this.user_id = user_id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getScreen_name() {
            return screen_name;
        }

        public void setScreen_name(String screen_name) {
            this.screen_name = screen_name;
        }

        public String getProfile_image() {
            return profile_image;
        }

        public void setProfile_image(String profile_image) {
            this.profile_image = profile_image;
        }

        public String getCreated_at() {
            return created_at;
        }

        public void setCreated_at(String created_at) {
            this.created_at = created_at;
        }

        public Object getCreate_time() {
            return create_time;
        }

        public void setCreate_time(Object create_time) {
            this.create_time = create_time;
        }

        public String getPasstime() {
            return passtime;
        }

        public void setPasstime(String passtime) {
            this.passtime = passtime;
        }

        public String getLove() {
            return love;
        }

        public void setLove(String love) {
            this.love = love;
        }

        public String getHate() {
            return hate;
        }

        public void setHate(String hate) {
            this.hate = hate;
        }

        public String getComment() {
            return comment;
        }

        public void setComment(String comment) {
            this.comment = comment;
        }

        public String getRepost() {
            return repost;
        }

        public void setRepost(String repost) {
            this.repost = repost;
        }

        public String getBookmark() {
            return bookmark;
        }

        public void setBookmark(String bookmark) {
            this.bookmark = bookmark;
        }

        public String getBimageuri() {
            return bimageuri;
        }

        public void setBimageuri(String bimageuri) {
            this.bimageuri = bimageuri;
        }

        public Object getVoiceuri() {
            return voiceuri;
        }

        public void setVoiceuri(Object voiceuri) {
            this.voiceuri = voiceuri;
        }

        public Object getVoicetime() {
            return voicetime;
        }

        public void setVoicetime(Object voicetime) {
            this.voicetime = voicetime;
        }

        public Object getVoicelength() {
            return voicelength;
        }

        public void setVoicelength(Object voicelength) {
            this.voicelength = voicelength;
        }

        public String getStatus() {
            return status;
        }

        public void setStatus(String status) {
            this.status = status;
        }

        public String getTheme_id() {
            return theme_id;
        }

        public void setTheme_id(String theme_id) {
            this.theme_id = theme_id;
        }

        public String getTheme_name() {
            return theme_name;
        }

        public void setTheme_name(String theme_name) {
            this.theme_name = theme_name;
        }

        public String getTheme_type() {
            return theme_type;
        }

        public void setTheme_type(String theme_type) {
            this.theme_type = theme_type;
        }

        public String getVideouri() {
            return videouri;
        }

        public void setVideouri(String videouri) {
            this.videouri = videouri;
        }

        public int getVideotime() {
            return videotime;
        }

        public void setVideotime(int videotime) {
            this.videotime = videotime;
        }

        public String getOriginal_pid() {
            return original_pid;
        }

        public void setOriginal_pid(String original_pid) {
            this.original_pid = original_pid;
        }

        public int getCache_version() {
            return cache_version;
        }

        public void setCache_version(int cache_version) {
            this.cache_version = cache_version;
        }

        public String getPlaycount() {
            return playcount;
        }

        public void setPlaycount(String playcount) {
            this.playcount = playcount;
        }

        public String getPlayfcount() {
            return playfcount;
        }

        public void setPlayfcount(String playfcount) {
            this.playfcount = playfcount;
        }

        public String getCai() {
            return cai;
        }

        public void setCai(String cai) {
            this.cai = cai;
        }

        public Object getWeixin_url() {
            return weixin_url;
        }

        public void setWeixin_url(Object weixin_url) {
            this.weixin_url = weixin_url;
        }

        public String getImage1() {
            return image1;
        }

        public void setImage1(String image1) {
            this.image1 = image1;
        }

        public String getImage2() {
            return image2;
        }

        public void setImage2(String image2) {
            this.image2 = image2;
        }

        public boolean isIs_gif() {
            return is_gif;
        }

        public void setIs_gif(boolean is_gif) {
            this.is_gif = is_gif;
        }

        public String getImage0() {
            return image0;
        }

        public void setImage0(String image0) {
            this.image0 = image0;
        }

        public String getImage_small() {
            return image_small;
        }

        public void setImage_small(String image_small) {
            this.image_small = image_small;
        }

        public String getCdn_img() {
            return cdn_img;
        }

        public void setCdn_img(String cdn_img) {
            this.cdn_img = cdn_img;
        }

        public String getWidth() {
            return width;
        }

        public void setWidth(String width) {
            this.width = width;
        }

        public String getHeight() {
            return height;
        }

        public void setHeight(String height) {
            this.height = height;
        }

        public String getTag() {
            return tag;
        }

        public void setTag(String tag) {
            this.tag = tag;
        }

        public int getT() {
            return t;
        }

        public void setT(int t) {
            this.t = t;
        }

        public String getDing() {
            return ding;
        }

        public void setDing(String ding) {
            this.ding = ding;
        }

        public String getFavourite() {
            return favourite;
        }

        public void setFavourite(String favourite) {
            this.favourite = favourite;
        }

        public Object getTop_cmt() {
            return top_cmt;
        }

        public void setTop_cmt(Object top_cmt) {
            this.top_cmt = top_cmt;
        }

        public Object getThemes() {
            return themes;
        }

        public void setThemes(Object themes) {
            this.themes = themes;
        }
    }
}

接口

public interface OnListItemClick {
    void OnItemClick(int position);
}

適配器xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    >
    <ImageView
        android:scaleType="fitXY"
        android:id="@+id/iv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/tv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章