Soru & Cevap

Kod ile birden fazla cardview oluşturma ...

20.06.2019 - 07:04

Merhaba elimde böyle bir cardview komponenti var ben bunu veritabanından gelen veri sayısı kadar oluşturmak istiyorum nasıl yapabilirim?

<?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=".AnasayfaFragment"
    android:id="@+id/linearHomePage">

    <!-- TODO: Update blank fragment layout -->

        <android.support.v7.widget.CardView
            android:id="@+id/cardView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="70dp"
            app:cardCornerRadius="10dp"
            android:background="@android:color/holo_red_light"
            >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="16dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textView1"
            android:layout_alignParentTop="true"
            android:textSize="30sp"
            android:text="İbrahim Enes Çiftçi"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textView2"

            android:layout_alignParentTop="true"
            android:layout_below="@+id/textView1"
            android:text="Developer"/>
    </RelativeLayout>
        </android.support.v7.widget.CardView>
</LinearLayout>

 

37 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-16838-1420450309.jpg
brhngk
21.09.2019 - 12:48

https://www.android-examples.com/create-cardview-programmatically-in-android-app/

 

Burada siz sadece tasarımı istediğinz gibi değiştirebilirsiniz.