Retrofit Kütüphanesi ile JSON Parsing Kullanımı
Retrofit Kütüphanesi Json formatında olan verileri kolay bir şekilde işlememize olanak sağlar. Basit bir örnek yaparak anlamaya çalışalım. JSON verilerimizi bu linkten çekerek CardView içine ekleyeceğiz CardView’leri ReyclerView içine aktararak göstermeye çalışacağız. İlk olarak build.gradle dosyamızda gerekli eklemeleri yapalım.
1 2 3 4 |
compile 'com.android.support:recyclerview-v7:26.1.0' compile 'com.android.support:cardview-v7:26.1.0' compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4' compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4' |
build.gradle dosyamızın son hali aşağıdaki olması gerekiyor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
apply plugin: 'com.android.application' android { compileSdkVersion 26 defaultConfig { applicationId "com.example.esatgozcu.retrofitjsonparsingkullanimi" minSdkVersion 15 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' compile 'com.android.support:recyclerview-v7:26.1.0' compile 'com.android.support:cardview-v7:26.1.0' compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4' compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4' } |
Öncelikle çekeceğimiz JSON verilerini aktaracağımız CardView dizaynımızı…
Devamı
SON YORUMLAR