1

I'm using Html.fromhtml to insert image in an editText ... but the instead of displaying the image, it displays [obj] " the text obj inside a square" what could be the problem ?? This is the imageGetter

ImageGetter imageGetter = new ImageGetter() {
public Drawable getDrawable(String source) {
Drawable d = getResources().getDrawable(R.drawable.e11);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
 return d;
             }
          };

This is the code line:

CharSequence cs = 
Html.fromHtml("<img src='" +getResources().getDrawable(R.drawable.e11)+ "'/>"
,imageGetter, null);
Android
  • 51
  • 6

2 Answers2

0

A better way to do this would be to add a WebView.

Phil
  • 35,852
  • 23
  • 123
  • 164
0

Your imageGetter instance is not doing the correct thing. Where is it trying to retrieve the images from and what does it look like?

Femi
  • 64,273
  • 8
  • 118
  • 148
  • the image i want to retrive is located in Drawable folder ... (local resource) it is called e11.png – Android Aug 21 '11 at 14:37
  • where is the problem, please ? – Android Aug 21 '11 at 14:45
  • Where is the code for your `imageGetter` instance? That is the problem: it is not retrieving the correct image. – Femi Aug 21 '11 at 18:01
  • ok I will edit the post .. and add the function there .. ok ? – Android Aug 21 '11 at 19:22
  • by the way .. i tried it in application with editText .. and i was able to see the image in the editText buttttttt when i use the same code in softkeyboard application i see the obj squares ... – Android Aug 21 '11 at 19:41
  • Might be that the soft keyboard runs in a process that doesn't have access to your application's resources? – Femi Aug 21 '11 at 20:36
  • this code is inside the softkeyboard class and the images are in the res folder of the same application – Android Aug 21 '11 at 20:40