Good evening everyone! I have a database. In the markup textview and there I take out of the database. In string, the cell contains, for example:

<![CDATA[ <h2>Стих </h2> У лукоморья дуб <font color="green">зеленый</font>;<br> Златая цепь на дубе том: <br> И днём и ночью <b>кот учёный</b> <br> Всё ходит по цепи кругом; <br> Идёт <b>направо</b> - песнь заводит, <br> <img src="header" /><br/><br/> <b>Налево</b> - сказку говорит. <br> Златая цепь на дубе том: <br> И днём и ночью <b>кот учёный</b> <br> <img src="file:///android_asset/header3.jpg"><br/><br/> 

In MainActivity

  TextView tv = (TextView) findViewById(R.id.txt); tv.setText(Html.fromHtml(getResources().getString(R.string.txt))); 

But instead of the pictures, these squares. What to do to have photos? Naturally, the pictures I placed in the assets. Tried and with drawable. And will they work if you consider that this is a SQLite database? Thank.

  • They do not seem to be loading. read about ImageGetter - Artem

1 answer 1

I wrote did not check well, I think the essence is clear

  public class ActivityOne extends Activity implements ImageGetter{ TextView new; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.help_menu); String code = "текст: <img src = 'ссылка' > текст.</p></td>"; new = (TextView) findViewById (R.id.new); Spanned spanned = Html.fromHtml(code, this, null); new.setText(spanned); } @Override public Drawable getDrawable(String arg) { LevelListDrawable d = new LevelListDrawable(); Drawable empty = getResources().getDrawable(R.drawable.ic_launcher); d.addLevel(0, 0, empty); d.setBounds(0, 0, empty.getIntrinsicWidth(), empty.getIntrinsicHeight()); Glide.with(this).load(arg).into(d); return d; } } 

If you don't want to use Glide, there are examples https://stackoverflow.com/questions/16179285