主要目標是使用預先製作的佈局創建可編輯的單獨模塊,然後以編程方式將它們添加到根佈局。爲了澄清,several modules stuck together would look like this.我想動態創建由名稱,日期和字母組成的每個可點擊的塊。將各塊的.axml代碼如下:有沒有辦法以編程方式在android中創建佈局的副本?
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/borderLayout"
android:background="@drawable/line"
android:paddingBottom="1dp"
android:paddingTop="1dp">
<RelativeLayout
android:id="@+id/relativeLayout1"
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:background="#ff2f2f2f">
<TextView
android:text="C"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:layout_alignParentLeft="true"
android:textSize="30dp" />
<TextView
android:text="Washington"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/textView1"
android:id="@+id/textView2"
android:layout_alignParentRight="true"
android:gravity="right" />
<TextView
android:text="6-8-17"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView2"
android:id="@+id/textView3"
android:gravity="right"
android:layout_alignParentRight="true" />
</RelativeLayout>
</RelativeLayout>
我有在我格式化他們在.axml文件的方式編程格式的意見的主要問題。
謝謝,這真的很有幫助! –