Sunday, August 27, 2017

Menggunakan Listview untuk tampilkan data web service dengan Android-query Library

Hii Codinggers, Assalammualaikum Warahmatulahi wabarakatuh, salam sejahtera, Alhamdulilah big thanks to God who has given us the best Nikmat.
Materi  Json Parse ini menggunakan Andorid-Aquery saya dapatkan mengkuti kegitan IAK (Indonesia Android Kejar), salah satu kegiatan utama Google bekerjasama dengan pemerintah Indonesia untuk menciptakan 1000-100.000 developer mobile.

Baca Tips Jadi Jitu Jadi Proggrammer

Gambar aplikasinya : Aplikasi menampilkan populasi penduduk.

 IAK di adakan di kantor Imastudio, pada tanggal 27/08/207 , pada tau apa itu  Imastudio? imastudio itu salah satu tempat/studio pelatihan untuk calon-calon developer mobile (Android/IoS) dengan harga yang sangat terjangkau, dan pelayanan yang sangat memuaskan. Saya belajar sudah 2 minggu dan merasakan suasana belajar yang menyenangkan, pokoknya you feel gembira lah, saat mengikuti traningnya, kenapa ? iyalah karena para trainernya yang masih muda tetapi pengetahuan tentang mobile proggrammingnya waaww !! mereka bukan saja memberikan cara menulis code itu bagaimana, tetapi mereka memberikan contoh-contoh yang anak muda - orang dewasa (more than 40 years) bisa mengerti karena mereka menyampaikan bahasa pemoggramman itu so easy to understanding, bukan saja itu Free mengulang sepuasnya, dan Surely, untuk masalah Gizi (Makanan) terjamin enak, ada snack available (banyak dan banyak snacknya) yang dari luar kotapun ngak perlu khawatir bisa tidur dan mandi dikantornya. Di IAK kami mendapat materi dari Mas Riski Syaputra salah satu trainer mobile proggraming di Imastudio sekaligus seorang guru di SMK Idn Madinatul Ilmi yang siswanya pada angkatan tahun ini (2017) menggunakan MacBook (Jursusan RPL), dan salah satu (satu-satunya) sekolah di indonesia yang kurikulumnya ada develop App IoS (Swift Proggramming).
IAK 27/08/2017


oh Iya' yang di bagian atas itu hanya pengantar saja ya para Codinggers, tambahan informasi buat kalian yang ingin belejar dan menjadi expert proggrammer.

Baca ini tutorial menampilkan daftar wisata

langsung saja kita pada tutorialnya, disini kita menggunakan libray Android-aquery download disini librarynya, kita juga menggunakan libaray picasso untuk menampilkan image, untuk dependecis bisa dilihat dibawah ini :


apply plugin: 'com.android.application'

android {
    compileSdkVersion
26
   
buildToolsVersion "26.0.1"
   
defaultConfig {
        applicationId
"com.blogbasbas.parsingdatajson"
       
minSdkVersion 16
       
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 {
    compile fileTree(
include: ['*.jar'], dir: 'libs')
    androidTestCompile(
'com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude
group: 'com.android.support', module: 'support-annotations'
   
})
    compile
'com.android.support:appcompat-v7:26.+'
   
compile 'com.android.support.constraint:constraint-layout:1.0.2'
   
testCompile 'junit:junit:4.12'
   
compile 'com.android.support:cardview-v7:26+'
   
compile 'com.jakewharton:butterknife:8.8.1'
   
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
   
compile files('libs/android-query-full.0.24.3.jar')
    compile
'com.squareup.picasso:picasso:2.5.2'
}

libararynya

untuk api servicenya kita menggunakan API service ini, bisa kalian gunakan.

file layout acitivty_main.xml
<?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:orientation="vertical"

    android:layout_height="match_parent"

    tools:context="com.blogbasbas.parsingdatajson.MainActivity">

    <ListView

        android:id="@+id/listview"

        android:layout_width="match_parent"

        android:layout_height="match_parent"></ListView>

</LinearLayout>

file list_item.xml untuk custom view di listview

<?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"

    android:layout_marginTop="8dp"

    android:layout_marginLeft="10dp"

    android:layout_marginRight="10dp"

    android:layout_marginBottom="4dp"

    android:background="@color/colorPrimaryDark"

    tools:context="com.blogbasbas.parsingdatajson.DetailActivity">



    <android.support.v7.widget.CardView

        app:cardCornerRadius="10dp"

        android:layout_width="match_parent"

        android:layout_height="wrap_content">

        <LinearLayout

            android:orientation="horizontal"

            android:layout_width="match_parent"

            android:layout_height="wrap_content">



            <ImageView

                android:id="@+id/imgList"

                android:layout_width="50dp"

                android:layout_height="50dp"

                android:src="@drawable/imgno" />



            <LinearLayout

                android:gravity="center"

                android:layout_weight="1"

                android:orientation="vertical"

                android:layout_width="wrap_content"

                android:layout_height="wrap_content">

    <TextView



        android:textStyle="bold"

        android:text="Rank  "

        android:layout_width="match_parent"

        android:layout_height="wrap_content" />

    <TextView



        android:textStyle="bold"

        android:text="Country  "

        android:layout_width="match_parent"

        android:layout_height="wrap_content" />

    <TextView



        android:textStyle="bold"

        android:text="Population"

        android:layout_width="match_parent"

        android:layout_height="wrap_content" />





            </LinearLayout>

            <LinearLayout

                android:gravity="center"

                android:layout_weight="1"

                android:orientation="vertical"

                android:layout_width="wrap_content"

                android:layout_height="wrap_content">

                <TextView



                    android:id="@+id/tvRankItem"

                    android:text="Rank"

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content" />

                <TextView



                    android:id="@+id/tvCountryItem"

                    android:text="Country"

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content" />

                <TextView
                    android:id="@+id/tvPopulationItem"

                    android:text="Population"

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content" />

            </LinearLayout>

        </LinearLayout>

    </android.support.v7.widget.CardView>

</LinearLayout>


dan layout activity_detail.xml

<?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.blogbasbas.parsingdatajson.DetailActivity">
    <ImageView

        android:layout_marginTop="10dp"

        android:id="@+id/imgDetail"

        android:src="@drawable/imgno"

        android:layout_width="match_parent"

        android:layout_height="150dp" />

    <View

        android:background="@color/colorPrimary"

        android:layout_width="match_parent"

        android:layout_height="3dp">

    </View>

    <TextView

        android:textStyle="bold"

        android:text="Rank :"

        android:layout_width="match_parent"

        android:layout_height="wrap_content" />

    <TextView

        android:textSize="20sp"

        android:id="@+id/tvRank"

        android:text="Rank"

        android:layout_width="match_parent"

        android:layout_height="wrap_content" />

    <View

        android:background="@color/colorPrimary"

        android:layout_width="match_parent"

        android:layout_height="1dp">

    </View>

    <TextView

       android:textStyle="bold"

        android:text="Country :"

        android:layout_width="match_parent"

        android:layout_height="wrap_content" />

    <TextView

        android:textSize="20sp"

        android:id="@+id/tvCountry"

        android:text="Country"

        android:layout_width="match_parent"

        android:layout_height="wrap_content" />

    <View

        android:background="@color/colorPrimary"

        android:layout_width="match_parent"

        android:layout_height="1dp">

    </View>

    <TextView

        android:textStyle="bold"

        android:text="Population :"

        android:layout_width="match_parent"

        android:layout_height="wrap_content" />

    <TextView

        android:textSize="20sp"

        android:id="@+id/tvPopulation"

        android:text="Population"

        android:layout_width="match_parent"

        android:layout_height="wrap_content" />

</LinearLayout>


untuk lebih lengkapnya di clone  di github Download Disini, karena untuk menjelaskannya terlalu banyak filenya. jika anda masih binggung bisa langsung coment, as soon as possible i want answer.



Pernah dengar Kotlin? Baca Artikelnya Disini


NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post
NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post

iklan

 

Delivered by FeedBurner