Code example for ImageSpan

4
    } 
	public void insertIcon(int id){
		final SpannableString ss = new SpannableString(getText().toString()+"[smile]");  
        Drawable d = getResources().getDrawable(id);
        d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());  
        ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BASELINE);  
        ss.setSpan(span, getText().length(),getText().length()+"[smile]".length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); 
         
	 
		append(ss);
//		 ImageGetter imageGetter = new ImageGetter() { 
// 
//	    		public Drawable getDrawable(String source) { 
//	    			int id = Integer.parseInt(source); 
//	    			Drawable d = getResources().getDrawable(id); 
//	    			d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); 
//	    			return d; 
//	    		}  
//	    	}; 
//		append(Html.fromHtml("<img src='"+ R.drawable.smile +"'/>", imageGetter, null));  
	}