我有一個佈局,我必須包括幾次。它由一個TextView
和一個ImageView
:Android - 同一個不同的ID包括佈局
<ImageView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:background="@drawable/back2"
android:id="@+id/id_1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/id_2"
android:textSize="15dp"
android:typeface="sans"
android:textColor="#ffffff" />
現在我想以編程方式設置文本,但我面臨的問題是,該TextView
現在總是具有相同的ID,因爲我包括相同的佈局幾次。有沒有辦法以編程方式包含佈局,並始終更改每個包含的佈局的ID?
你爲什麼沒有動態地添加TextView的? –