新语言Kotlin使用recyclerview展示数据+retrofit请求数据+Rxjava

本文介绍了如何在Kotlin中利用RecyclerView展示数据,结合Retrofit进行网络请求,并通过RxJava进行数据订阅和处理。首先,添加相关依赖,然后创建主布局activity_main,定义Bean类和数据接口IGetDataBase。接着,在MainActivity中实现数据请求和适配器IAdapter的设置。
摘要由CSDN通过智能技术生成

依赖:

   compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.squareup.retrofit2:converter-scalars:2.3.0'
    compile 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'com.squareup.okhttp3:okhttp:3.9.0'
    compile 'io.reactivex.rxjava2:rxjava:2.1.7'

    compile 'com.github.bumptech.glide:glide:3.7.0'

权限:


<uses-permission android:name="android.permission.INTERNET"/>



布局

主布局activity_main

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.muhanxi.kotlindemo.MainActivity">


    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/recyclerview"/>


</
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值