android - How to make textview with drawable on the left which could be set programmatically from a url coming from server -
well, first step decode image url.
you this:
string yoururl = "http://someurl"; // insert url here // connect, instance of inputstream httpurlconnection connection = (httpurlconnection) new url(yoururl).openconnection(); inputstream inputstream = connection.getinputstream(); // decode stream bitmap , create drawable bitmap tempbitmap = bitmapfactory.decodestream(inputstream); drawable drawable = new bitmapdrawable(getresources(), tempbitmap);
and then, set compound drawable on left side of textview
:
// order left, top, right, bottom, need set first param yourtextview.setcompounddrawables(drawable, null, null, null);
Comments
Post a Comment