2011-01-12 60 views
0

我想以某种方式修改包含标签的合并布局的内容。那可能吗?如何从包含xml标签的合并布局中修改孩子文本?

布局picAndText.xml:

<merge xmlns:android="http://schemas.android.com/apk/res/android"> 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 

     android:scaleType="center" 
     android:src="@drawable/golden_gate" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="20dip" 
     android:layout_gravity="center_horizontal|bottom" 

     android:padding="12dip" 

     android:background="#AA000000" 
     android:textColor="#ffffffff" 

     android:text="Golden Gate" /> 

</merge> 

而且布局XML使用picAndText.xml:

<include layout="@layout/picAndText" android:id="@+id/picText" /> 

请注意,这是我想acomplish什么的例子。我想重复使用复杂的布局与多个孩子,但我需要不同的文字在他们每次重复使用这些,而不必复制整个布局无处不在...

谢谢! -Jona

回答

0

如果我明白你想要正确做什么,我不认为它可能来自XML。相反,您可以在代码中加载布局时更新文本。

+0

是的,我通过Android APIs读取,但似乎不可能,但我想问的原因,我想也许只是有一种方法... – Jona 2011-01-12 21:51:34

相关问题