몇개의 TextViews, ImageViews, Button을 가진 (복잡한) RelativeLayout을 가지고 있습니다. 이 레이아웃을 만드는 빈도는 데이터베이스의 데이터에 따라 다릅니다. 이 데이터를 목록에서 가져 와서 동적으로 표시하려면 무엇을해야합니까?xml을 동적으로 레이아웃에 추가하십시오.
XML을 동적으로 추가 :
이<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/zusatz_content" >
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:layout_marginRight="15dp"
android:layout_marginLeft="15dp"
android:text="Lorem Ipsum 1" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text2"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="@string/button_desc" />
<ImageView
android:id="@+id/image"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="@+id/text1"
android:layout_centerHorizontal="true"
android:contentDescription="@string/ima_zusatz_desc"
android:src="@drawable/nix" />
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/text1"
android:layout_below="@+id/image"
android:text="Lorem Ipsum 2" />
주의 사항 : 텍스트와 이미지가 데이터베이스에서 콘텐츠를 동적으로 변경해야합니다. 당신의 XML 게다가
덕분에, TOMTOM
당신이 묻고있는 것이 명확하지 않습니다. –
이러한 레이아웃을 부모 레이아웃에 프로그래밍 방식으로 추가하는 방법 –