Code example for Spannable

Methods: setText, getSpanEnd, getSpanStart, removeSpan, setSpan

0
 
				// now we create a new ImageSpan 
				ImageSpan newImg = new ImageSpan(d, img.getSource());
 
				// find the position of the old ImageSpan 
				int start = htmlSpannable.getSpanStart(img);
				int end = htmlSpannable.getSpanEnd(img);
 
				// remove the old ImageSpan 
				htmlSpannable.removeSpan(img);
 
				// add the new ImageSpan 
				htmlSpannable.setSpan(newImg, start, end,
						Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
 
				//finally we have to update the TextView with our 
				// updates Spannable to display the image 
				htmlTextView.setText(htmlSpannable);
			//} else { 
			//	Log.e(TAG, "File NOT FOUND = Download error"); 
				 
			//} 
		}