this question has answer here:
- html.imagegetter textview 3 answers
i try display text , image in html.fromhtml()
doesn't work in image display.
message = (textview) findviewbyid (r.id.message); message.settext(html.fromhtml( "<p><b>first, </b><br/>" + "please press the" + "<img src = 'addbutton.png' />" + " insert new event.</p>"));
the text display image cannot display. how can improve it?
this coding reference user pskink...
package com.tutorial.myjob; import android.app.activity; import android.graphics.drawable.drawable; import android.graphics.drawable.levellistdrawable; import android.os.bundle; import android.text.*; import android.text.html.imagegetter; import android.widget.*; public class helpmenu extends activity implements imagegetter{ textview message; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.help_menu); string code = "<p><b>first, </b><br/>" + "please press <img src ='addbutton.png'> button beside insert new event.</p>" + "<p><b>second,</b><br/>" + "please insert details of event.</p>" "<p>the icon of show level of event.<br/>" + "eg: <img src = 'tu1.png' > easier do.</p></td>"; message = (textview) findviewbyid (r.id.message); spanned spanned = html.fromhtml(code, this, null); message.settext(spanned); message.settextsize(16); } @override public drawable getdrawable(string arg0) { // todo auto-generated method stub int id = 0; if(arg0.equals("addbutton.png")){ id = r.drawable.addbutton; } if(arg0.equals("tu1.png")){ id = r.drawable.tu1; } levellistdrawable d = new levellistdrawable(); drawable empty = getresources().getdrawable(id); d.addlevel(0, 0, empty); d.setbounds(0, 0, empty.getintrinsicwidth(), empty.getintrinsicheight()); return d; } }
this edit... these coding run me... lot helping me... appreciated~ ^^
Comments
Post a Comment