Q:

Problem in displaying the image in Textiew Using the Html.ImageGetter

I want to display image in TextView with text, I had used Html.ImageGetter but image was not displayed this is my code, please tell me what is wrong in this code
public class MyTest extends Activity {

TextView t=null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    t=(TextView)findViewById(R.id.textcode);

    t.setText(Html.fromHtml("Hi", imgGetter, null));

}

private ImageGetter imgGetter = new ImageGetter() {

    public Drawable getDrawable(String source) {
            Drawable drawable = null;
            try {

                    drawable = getResources().getDrawable(R.drawable.icon);
                    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable
                                    .getIntrinsicHeight());

            } catch (Exception e) {
                    e.printStackTrace();
                    Log.d("Exception thrown",e.getMessage());
            } 
            return drawable;
    }
};

}

A:

ImageGetter is used for <img> tag parsing. So you have to have an <img> tag in your HTML code. For example,
t.setText(Html.fromHtml("Hi <img src='some_image'>", imgGetter, null));

But you'd better make the ImageGetter subclass return an image depending on the source argument.

