String icon

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

String icon

Postby gerry013 » Fri Aug 28, 2009 2:41 pm

Hi!

I would like to put an icon into a String:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public String toString() {
  2.  
  3.     SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
  4.  
  5.     String dateString = sdf.format(date);
  6.  
  7.     return "Icon: " + android.R.id.icon + " " + dateString;
  8.  
  9.   }
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


But I get the "number" of the icon, not the image:

Icon: 16908294 13:43

Can somebody show me how to do it?
Many thanks!
gerry013
Freshman
Freshman
 
Posts: 3
Joined: Fri Aug 28, 2009 2:35 pm

Top

Postby WarrenFaith » Fri Aug 28, 2009 4:34 pm

What did you mean with "putting an image into a string"?

To get a bitmap from your icon, you can try this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. BitmapFactory.decodeResource(getResources(), R.drawable.icon)
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
in your Activity class....
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Postby gerry013 » Fri Aug 28, 2009 5:40 pm

Many thanks
gerry013
Freshman
Freshman
 
Posts: 3
Joined: Fri Aug 28, 2009 2:35 pm

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 6 guests