I can not show the image that is saved in the res / drawable folder. For this I use ImageGetter. Code below:
ImageGetter imageGetter3 = new ImageGetter() { public Drawable getDrawable(String source) { int id=0; if (source.equals("smiley")) { id = R.drawable.smiley; } Drawable d = getResources().getDrawable(id); d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); return d; } }; directions += "Je bent bij lokaal " + vertrek.getNaam() + "\n" + "Sta met je rug voor de deur\n" + Html.fromHtml("<img src=\"smiley\">", imageGetter3, null) + " Draai naar links\n";
What I see on the screen at startup is a small square with the text "obj". So what is wrong? Image cannot be read or something else? How to display images?
Honestly, I have a lot of Googled and tried other ImageGetter methods, but none of them seem to work, I also tried them, they do not work:
ImageGetter imageGetter2 = new ImageGetter() { public Drawable getDrawable(String source) { Drawable d = null; d = Drawable.createFromPath(source); d.setBounds(0,0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); return d; } }; ImageGetter imageGetter = new ImageGetter() { public Drawable getDrawable(String source) { Drawable drawFromPath; int path = Route.this.getResources().getIdentifier(source, "drawable","com.prj56.tracingapp"); drawFromPath = (Drawable) Route.this.getResources().getDrawable(path); drawFromPath.setBounds(0, 0, drawFromPath.getIntrinsicWidth(), drawFromPath.getIntrinsicHeight()); return drawFromPath; } };
==================================================== ======= if (....) {ImageView iv1 = new ImageView (this); iv1.setImageResource (R.drawable.smiley);
directions += "Je bent bij lokaal " + vertrek.getNaam() + "\n" + "Sta met je rug voor de deur\n"; HERE COMES THE IMAGE! BUT HOW TO DO THIS? It within directions textview... directions += " Draai naar links\n"; }
Yanny source share