Kotlin practice, call Restful API with Retrofit, and update RecyclerView.
Add permission in "AndroidManifest.xml".
<uses-permission android:name="android.permission.INTERNET"/>
Add libs in "build.gradle".
buildFeatures{
viewBinding true
}
//Retrofit2
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
//Coil
implementation("io.coil-kt:coil:1.3.2")
Add plugin "JSON To Kotlin Class" in Android Studio.
Select Android Studio > Perfeneces... > Plugins > Marketplace
Key "JSON To Kotlin Class" in search table, then install it.
Start practice.
Sample API from "臺北旅遊網Open API - 台北" 臺北旅遊網Open API - 台北