0

I have an application that is suppose to be built in English and Arabic. so i have drawable-en and drawable-ar.

My question is, is it better to set the images in XML, because android will figure out which language is selected and to show the appropriate image. Or i do this through code and check for language and set its image. I don't want the application to crash with memory error etc.

Method 1: android:background="@drawable/background2"

Method 2: //here some cache is put into work.

 ImageResourceHandler.RenderImageBackgroundForView(getResources(), findViewById(R.id.imageView), R.drawable.activitybackground);

//this is direct image set to backgroup

((Button) findViewById(R.id.languageButton)).setBackgroundResource(R.drawable.langeng);

Thanks in advance.

4

1 回答 1

1

因为android会找出选择了哪种语言并显示适当的图像

您解决了自己的问题;)这是 Android 的工作方式。

另一种方式也是可能的,但更少的代码更容易维护

于 2013-01-19T07:46:42.743 回答