android - How to make textview with drawable on the left which could be set programmatically from a url coming from server -


textview programmable drawable on left

how make textview drawable on left that(drawable) can set programmaticaly url coming 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

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -