1

我有活动 A 和活动 B。它们都使用相同的布局,但主题不同。现在定义不同的属性,例如 textColor 是这样完成的

<item name="android:textColor">#00FF00</item>

但我想做一些不同的事情。我想为“ImageView01”元素提供不同的图像

<ImageView android:layout_width="wrap_content" android:id="@+id/ImageView01" android:background="@drawable/attachment1" android:layout_height="wrap_content"></ImageView>

“ImageView01”存在于活动A和B中。但我希望A中的元素“ImageView01”有不同的图像,活动B中的元素“ImageView01”有不同的图像。

这可能吗?

4

1 回答 1

0

在您的 inResume() 方法中有 Activity A:

ImageView iv = (ImageView) findViewById(R.id.ImageView01);
iv.setBackgroundResource(R.drawable.attachment1);

在活动 B

ImageView iv = (ImageView) findViewById(R.id.ImageView01);
iv.setBackgroundResource(R.drawable.attachment2);
于 2011-08-24T12:21:00.947 回答