Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - imageview resource as string imagename from drawable folder

imageview resource as string imagename from drawable folder

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

imageview resource as string imagename from drawable folder

Postby faisalloe » Tue Dec 01, 2009 5:35 am

hello,

I am having lots of images in drawable folder.

I want to set imageview's imageView.setimage* by providing image name as a argument instead of providing reference of R.drawable.imageName
faisalloe
Developer
Developer
 
Posts: 29
Joined: Wed Nov 04, 2009 5:01 am

Top

Postby XCaffeinated » Wed Dec 02, 2009 2:39 am

Hi Faisalloe,

There's no way to pass a string directly to .setImage() , but if you want you can load all your strings into a hashmap like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. HashMap<String, Integer> m = new HashMap<String, Integer>();
  2.  
  3. m.put("my_pic1.png", R.drawable.my_pic1);
  4.  
  5. m.put("my_pic2.png", R.drawable.my_pic2);
  6.  
  7. //...
Parsed in 0.012 seconds, using GeSHi 1.0.8.4


then retrieve the appropriate resource id when you need it, for example:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. int resid = m.get("my_pic2.png");
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


and use it as .setImageResource(resid).

This will work in a pinch, but it won't be very fast and you will clutter up your code with a lot of string data. What is it you are trying to accomplish?

XCaf
XCaffeinated
Developer
Developer
 
Posts: 25
Joined: Sun Nov 29, 2009 10:16 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests