开发者

Different image in different theme or style

I have activity A and activity B. They both use the the same layout but they have different theme. Now defining diff开发者_Python百科erent properties for example textColor is done like this

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

but I want to do something different. I want to have different images for "ImageView01" element

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

the "ImageView01" is present in activity A and B. but I want to have different image for element "ImageView01" in A and different image for element "ImageView01" in activity B.

is this possible at all ?


In your inResume() methods have in Activity A:

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

and in Activity B

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜