To provide you with some methods, you can directly take to use, TextView in the code{code} set up and down around the settings picture. There are several ways to do this, and this gives you some examples.
The following methods are recommended in the Util tool class, where the benefits do not have to be told more.
,//resource ID public static void settextdrawable (context context, int drawableres,//resource ID
TextView tvname) {
drawable drawabletop = Context.getresources (). getdrawable (Drawableres);
The picture size must be set or not displayed
Drawabletop.setbounds (0, 0, drawabletop.getminimumwidth (),
Drawabletop.getminimumheight ());
Tvname.setcompounddrawables (NULL, drawabletop, NULL, NULL);
}
Bitmap
public static void Settextdrawable (context context, Bitmap Bitmap,
TextView tvname) {
drawable drawabletop = bitmaputils.bitmap2drawable (bitmap);
The picture size must be set or not displayed
Drawabletop.setbounds (0, 0, drawabletop.getminimumwidth (),
Drawabletop.getminimumheight ());
Tvname.setcompounddrawables (NULL, drawabletop, NULL, NULL);
}
Network URL Path
public static void Settextdrawable (context context, String URL,
Final TextView TextView) {
Imageloader.getinstance (). LoadImage (URL, new Imageloadinglistener () {
public void onloadingstarted (String arg0, View arg1) {
}
public void onloadingfailed (String arg0, View arg1, Failreason arg2) {
}
public void Onloadingcomplete (String arg0, View arg1, Bitmap Bitmap) {
drawable drawabletop = bitmaputils.bitmap2drawable (bitmap);
The picture size must be set or not displayed
Drawabletop.setbounds (0, 0, drawabletop.getminimumwidth (),
Drawabletop.getminimumheight ());
Textview.setcompounddrawables (NULL, drawabletop, NULL, NULL);
}
public void onloadingcancelled (String arg0, View arg1) {
}
});
}
There are three methods, each of which is set differently for each method. If there are other problems, I hope that the great God more guidance.
If you want to set up a picture in XML, then you just need a word android:drawabletop= "@drawable/ic_launcher"
This article is from the "Java" blog, so be sure to keep this source http://10594050.blog.51cto.com/10584050/1731578
Android TextView set picture and XML settings picture in code