0

I am developing app where get one XML . I parse this XML . I get the images name of like logoldpi ,logomdpi ,logohdpi ,logoxh dpi . now I need to set these image according to device dpi.I have set these image acccording to device dpi but in case my device is hdpi and i get logohdpi null then i need to set logomdpi if it is null then logoldpi how to solve this ?

Please help.

Thanks in advance.

eva
  • 31
  • 6

1 Answers1

0

Make different drawable folders for different resolutions. Eg ldpi - drawable-ldpi hdpi - drawable-hdpi mdpi - drawable-mdpi xhdpi - drawable-xhdpi

and put the images accordingly in these folders and android os will pick them accordingly.

Suhail Mehta
  • 5,514
  • 2
  • 23
  • 37
  • Thanks , but in my case i want to know the logic how to implement this if i am not getting image of respective device than i need to set lower dpi image on device – eva Nov 24 '13 at 06:38
  • take that image in only drawable folder.when you dont get any of the image according to the resolution it will pick it from the drawable folder – Suhail Mehta Nov 24 '13 at 10:22
  • Thanks @Sunhail ,but i am getting image name from xml file at run time. and actually i am downloading a zip file which contain one xml that give the image name as per the device resolution . i need to set proper image if i get that image name null then i need to set lower resolution image name. – eva Nov 24 '13 at 16:23
  • then you can catch the null pointer Exception and do the need full at that time – Suhail Mehta Nov 25 '13 at 06:03