Bu dersimizde recyclerview uygulamamıza başlıyoruz. Adım adım ilerleyerek kafalarımızı karıştırmadan örneğimizi gerçekleştiricez.
1.adımımız listemizin tek satırının layoutunu hazırlamakla başlıyoruz. Bunu yaparken root layout olarak linear/relative layout değil de cardview olarak seçiyoruz. cardview view öğesini kullanabilmek için bunu da build.gradle dosyasına dependency kısmına ilgili kütüphaneyi yazıyoruz. (com.adnroid.support:cardview-v7:25.1.1)
Bu derste yazılan kodlar aşağıdaki gibidir. Uygulamanın bitmiş halini ve kullanılan resimleri indirmek için LÜTFEN BURAYI tıklayınız…..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.emrealtunbilek.materialrecyclerviewornek.MainActivity"> <android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/recyclerview" > </android.support.v7.widget.RecyclerView> </RelativeLayout> |
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="5dp" app:cardCornerRadius="5dp" android:id="@+id/rootCardView" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/white" android:orientation="horizontal" > <ImageView android:layout_width="60dp" android:layout_height="60dp" android:id="@+id/imgManzara" android:src="@drawable/thumb_1_0" /> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:orientation="vertical" android:layout_weight="1" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Manzara" android:textSize="18sp" android:id="@+id/tvManzaraBaslik" android:textStyle="bold" android:layout_margin="7dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Manzara Tanım" android:textSize="14sp" android:id="@+id/tvManzaraTanim" android:textStyle="italic" android:layout_marginLeft="7dp" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:layout_width="20dp" android:layout_height="20dp" android:layout_margin="7dp" android:id="@+id/imgSil" android:tint="@color/colorAccent" android:src="@drawable/ic_delete"/> <ImageView android:layout_width="20dp" android:layout_height="20dp" android:layout_margin="7dp" android:id="@+id/imgKopyala" android:tint="@color/colorAccent" android:src="@drawable/ic_make_copy"/> </LinearLayout> </LinearLayout> </android.support.v7.widget.CardView> |
Eline emeğine sağlık çok yararlı oluyor.
s.a
hocam çok güzel anlatmışsınız elinize sağlık hepsini izledim.
ancak listedeki her ögeye nasıl tıklayacaz mesela 1. sıradaki listeye tıklayınca bir geniş açıklama metni çıkarmak istiyorum bunu nasıl yapacagız.
tşk.